Odoo Help


debugging python code

on 8/17/13, 2:41 AM 3,981 views
I have been trying different debugging methods but everything fails.How can i print a variable or msg in log.

i am using tail -f /var/log/openerp/openerp-server.log& for log

my code is 
import logging
from openerp.osv import fields, osv
import time
print "a"*1000

_logger = logging.getLogger(__name__)
class calldata_print_report_wiz(osv.osv_memory):
    _name = "calldata.print.report.wiz"

    def _sel_func(self, cr, uid,context=None):

     print "hello"*100
     obj = self.pool.get('calldata1')
     ids = obj.search(cr, uid, [])
     res = obj.read(cr, uid, ids, ['Caller'], context)
     _logger.debug('Create a %s with vals %s', self._name, res)
     res =[r['Caller'] for r in res]
     return res

    _columns = {
        'date_start': fields.date('Date Start', required=True),
        'date_end': fields.date('Date End', required=True),
#        'Callers':fields.many2one(
 #       'calldata1',

  #   'Callers',
   #     selection=_sel_func
    #    )
       'caller_id':fields.selection(_sel_func, string='Caller'),
    _defaults = {
        'date_start': lambda *a: time.strftime('%Y-%m-%d'),
        'date_end': lambda *a: time.strftime('%Y-%m-%d'),


    def print_report(self, cr, uid, ids, context=None):
      import pdb
       import netsvc
       netsvc.Logger().notifyChannel('calldetails1', netsvc.LOG_DEBUG, "Hello")

      if context is None:
            context = {}

      datas = {'ids': context.get('active_ids', [])}
      res = self.read(cr, uid, ids, ['date_start', 'date_end', 'Caller_id'], context=context)
      res = res and res[0] or {}
      datas['form'] = res
      return {
            'type': 'ir.actions.report.xml',

Any one please help?


AJ Schrafel Paper Corp

--AJ Schrafel Paper Corp--
| 4 5 8
Bronx, United States
--AJ Schrafel Paper Corp--

Exploring OpenERP for business

AJ Schrafel Paper Corp
On 8/17/13, 6:16 PM

Put the _logging declaration inside the function you want to log and start/stop the server. That will make the log messages start to appear

Also start the server in debug mode or change the logging from .debug to .info

Yes finally it worked thanks alot patently.

on 8/19/13, 1:40 AM



| 5 4 7
On 8/17/13, 6:59 AM

There could be several reasons:

  1. Have you restarted the server to apply new print statements?
  2. Be sure you are reading correct log file(perhaps you specified another one when started the server adding -c or config?). If you see current time reading your log the file you are reading is correct.
  3. Why are you launching reading the file as background process? You don't need '&' at the end of command.
  4. Go to Settings --> Configuration --> Database structure --> Objects and check whether there is such a model calldata.print.report.wiz in your database, if not - you forgot to include you file in __init_ section of module. Besides there is no reason to use pdb module in you code as it wouldn't work while you are only reading the file. Cheers.

yes i restarted the server. i restarted server using this command sudo /etc/init.d/openerp restart --debug .there exists calldata.print.report.wiz table in my database.Still why its not showing my print statement result :( ? my configuration file for open erp is /etc/openerp/openerp-server.conf
[options] ; This is the password that allows database operations: ; admin_passwd = admin db_host = False db_port = False db_user = openerp db_password = False

on 8/17/13, 8:14 AM

Append following line to conf file: logfile = /var/log/openerp/openerp-server.log and restart the server.

on 8/17/13, 8:37 AM

changed configuration and restarted . still no change :(.

on 8/17/13, 8:48 AM

Hm, is there any output in console after running tail -f /var/log/openerp/openerp-server.log and accessing server throw web browser?

on 8/17/13, 8:57 AM

yes it shows errors if any,login info etc

on 8/17/13, 8:58 AM

Ok, let's try the last thing - insert in your code next method: def init(self, cr): print "Hello World"*100 and restart the server. If it will not print - your module is not updating, otherwise try to use 'caller_id' as functional field, not selection.

on 8/17/13, 9:22 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)


Asked: 8/17/13, 2:41 AM
Seen: 3981 times
Last updated: 3/16/15, 8:10 AM