2

I am trying to debug code for QR Bar Code Labels in OpenERP 6 using Aptana Studio 3. I put a breakpoint in "pyqr" module, file "myfile.py", function "generate_image()", as per attached picture:

enter image description here

Now, when I run OpenERP server from Aptana IDE ("openerp-server.py" -> Debug As -> Python Run) and navigate to Manufacturing Orders where I can click on one of the right hand buttons "Large Label" or "Medium Label" or "Small Label", the debugger doesn't stop at the breakpoint and yet the label is printed in opened PDF file.

I have performed the following tests to check if the code in "myfile.py" executes. I have put "print" statement in "generate_image()" function, and it did not print anything in console. I put "import pdb" and "pdb.set_trace()" and the execution did not stop there. I added a message box in "generate_image()" function and message box did not display, yet the QR bar code label was created. It looks like that "myfile.py" code is not executed at all adding to mystery which code is executed that creates QR Bar Code labels.

How I can make debugger stop at this breakpoint? What am I missing?

Nash
  • 1,043
  • 2
  • 14
  • 33
  • I don't know the answer to you actual question - but I can see a bug in your code right there: instead of checking for "not context", you have to use "context is not None". Otherwise if I pass any object that has __nonzero__/__bool__ overloaded (as e.g. dicts) can't be passed as context. On top of that problem, you don't even *use* context, questioning it's existence in the first place. – deets Apr 20 '15 at 15:57

1 Answers1

2

To be able to debug in your IDE, I assume that you are running the Odoo server from source and start it from inside the IDE.

I'm not sure what is your actual setup, but maybe these pointers can help.

  • Try putting the breakpoint on a line of the method, instead of on it's definition.
  • Are you sure that the code is being executed? Try placing a print statement in it to confirm. Or try adding a import pdb; pdb.set_trace() line as a way to force a breakpoint.
Daniel Reis
  • 12,944
  • 6
  • 43
  • 71
  • Thanks, Daniel. I have put "print" statement, and it did not print anything in console. I put "pdb.set_trace()" and it did not stop there. Yes, I start the OpenERP server from inside IDE and debugger stops in other files. It looks like that "myfile.py" is not executed, but then it's a mystery because "pyqr" module is responsible for label printing, and the labels are, in fact, printed in PDF file. So, I wonder which code, then, executes the QR label print? – Nash Apr 21 '15 at 12:19
  • I even added a message box in "generate_image()" function (in "myfile.py") and is not executed. – Nash Apr 21 '15 at 13:56
  • The machine is always right: you can be sure that the function is not being called. Your error is elsewhere. – Daniel Reis May 01 '15 at 15:43