How to debug module

Asked by shanky

Hello,

I want to debug my sever side logic which is in the python file. I try with the command line python module

I followed some step:

Step-1) I reach in working directory:
/usr/lib/python2.5/site-packages/openerp-server/addons/travel

Step-2) I use python pdb module
travel]$ python -m pdb __init__.py

Step-3 Press Enter nd use the ("n","s","l") option

For following line i get error message :ImportError: No module named osv
-> from osv import osv, fields

I set PATH=$PATH:/usr/lib/python2.5/site-packages/openerp-server/osv

anyone help, is any better way to do it or i miss some step

Question information

Language:
English Edit question
Status:
Solved
For:
Odoo Addons (MOVED TO GITHUB) Edit question
Assignee:
No assignee Edit question
Solved by:
Naresh(OpenERP)
Solved:
Last query:
Last reply:
Revision history for this message
Vinay Rana (OpenERP) (vra-openerp) said :
#1

Hello Shankar,

OpenERP provide some debug option from server side terminal you can use those option.
The options is: '--debug' : enable debug mode.
You can use print statement manually inside the code.

Hope this will help you.
Thanks.

Revision history for this message
shanky (shankar-shinde-deactivatedaccount) said :
#2

Hello Vra,
Thanks for replay,

I was tried with "export PYTHONPATH=$PYTHONPATH" , It will need to create one python file which import all the required module.

shall you give example of command,

I am very new to UNIX environment and Openerp previously installed on server i don't know internal to much
Thanks

Revision history for this message
shanky (shankar-shinde-deactivatedaccount) said :
#3

Hello vra

I get debug option and other several option on page
http://doc.openerp.com/developer/1_1_Introduction/4_command_line.html

How to use them, there is no example.

Thanks

Revision history for this message
Best Naresh(OpenERP) (nch-openerp) said :
#4

shanky wrote:
> Question #107232 on OpenObject Addons changed:
> https://answers.launchpad.net/openobject-addons/+question/107232
>
> shanky gave more information on the question:
> Hello vra
>
> I get debug option and other several option on page
> http://doc.openerp.com/developer/1_1_Introduction/4_command_line.html
>
> How to use them, there is no example.
>
> Thanks
>
>
hello,

Start your server with the option you want.
for debugging use --debug

Revision history for this message
Vinay Rana (OpenERP) (vra-openerp) said :
#5

Hello Shankar,

You can take a reference from repository code.When you make repository link into active then at the time of calling Administration/Modules Management/Update Modules List wizard it will import the modules from specific URL in the repository form (Administration/Modules Management/Repository list).
The wizard code is exist in following path:
 server/bin/addons/base/module/wizard/wizard_update_module.py

The important line of code is :
    def _update_module(self, cr, uid, data, context):
        update, add = pooler.get_pool(cr.dbname).get('ir.module.module').update_list(cr, uid)
        return {'update': update, 'add': add}
Check the code of 'update_list' function which is defined in 'ir.module.module'.
Hope this will help you.

Thanks.

Revision history for this message
Vinay Rana (OpenERP) (vra-openerp) said :
#6

Hello Shankar,

You can take a reference from repository code.When you make repository link into active then at the time of calling Administration/Modules Management/Update Modules List wizard it will import the modules from specific URL in the repository form (Administration/Modules Management/Repository list).
The wizard code is exist in following path:
 server/bin/addons/base/module/wizard/wizard_update_module.py

The important line of code is :
    def _update_module(self, cr, uid, data, context):
        update, add = pooler.get_pool(cr.dbname).get('ir.module.module').update_list(cr, uid)
        return {'update': update, 'add': add}
Check the code of 'update_list' function which is defined in 'ir.module.module'.
Hope this will help you.

Thanks.

Revision history for this message
shanky (shankar-shinde-deactivatedaccount) said :
#7

Thanks nch(OpenERP), that solved my question.