There are a few ways, none of them all that great.
If you're looking for the value of a field that has been written to the database, use something like pgAdmin. Navigate to the table and show the records or write up an SQL line. The web client URL will have the id # and model name in it when you're viewing a particular record.
The quick, dumb way to check a value in the middle of a function is to put a print line in the code when you want to see its value. The value is printed to the console (or log file if you're using that instead). You need to stop the server and restart it whenever you change the python code, so it can recompile python bytecode with your change in it:
sale_rec = self.pool['sale.order'].browse(cr, uid, some_sale_id, context) print sale_rec.partner_id.name # Output in console: # Test Co.
Probably the best way to do this is for a lot of thorough testing to run OpenERP in debug mode in Eclipse with PyDev. Just insert a breakpoint anywhere in the python code and hover over a variable to see its value. The OpenERP client will just sit in the loading state and wait to be sent data. To set that up (assuming Ubuntu 12.04, make your own adjustments where needed):
1) Install Eclipse
sudo apt-get install eclipse
2) Install PyDev. Open Eclipse and go to 'Help' -> 'Install New Software...'. Click
Add... in the upper right corner. Set the name to
pydev and the location to
http://pydev.org/updates. Check the PyDev box that comes up in the list and click
3) Check Python Interpreter. In Eclipse, go to 'Window' -> 'Preferences' -> 'PyDev' -> 'Interpreter - Python'. Make sure the Python interpreter is listed. It should be named
/usr/bin/python and located in
/usr/bin/python2.7 if it's not there.
4) Create a PyDev project for OpenERP. In Eclipse, go to 'File' -> 'New' -> 'PyDev Project'. The name can be whatever you want, but make sure to uncheck
Use default for the project contents. Replace the directory with the folder containing all of your OpenERP code (server, addons, web modules, anything else), and click
5) Open PyDev Workspace. Go to 'Window' -> 'Open Perspective' -> 'Other...', and select
6) Start the Server. In the package explorer, navigate to the
openerp-server file, right click and go to 'Run As' -> '1 Python Run'. After that runs, go back and edit the run configuration. Switch to the Arguments tab and add your command line arguments, e.g.:
OpenERP as of 7.0 also has built-in Python debugging, but I'm not a huge fan of debugging in a terminal.
Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!
About This Community
|Asked: 5/31/13, 1:11 PM|
|Seen: 2185 times|
|Last updated: 3/16/15, 8:10 AM|