Help

3

How to make OpenERP take my python code modifications into account?

Avatar
Bonnet Denis

I've made a personal module:

import datetime
import time
from openerp.osv import fields, osv
import logging

_logger = logging.getLogger("WORK2MEETING")
class project_task_work(osv.osv):
    _name = "project.task.work"
    _inherit="project.task.work"
    _columns = {
        'meeting_id': fields.many2one('crm.meeting', 'Meeting')
    }

    def create(self, cr, uid, vals, *args, **kwargs):
        _logger.debug('Create a %s with vals %s', self._name, vals)
        meeting_obj = self.pool.get('crm.meeting')
        varDeadline= datetime.date.today()#TODO deadline=date+hours
        meeting_vals = {
            'name': vals['name'],
            #'categ_ids': ,#TODO récup l'id du tag "avancement de projet"
            'duration': vals['hours'],
            'description':task_id.project_id.name+'->'+task_id.name+'->'+name,
            'user_id': vals['user_id'].id,
            'date': vals['date'],
            'end_date': varDeadline,
            'date_deadline': varDeadline,
            'state': 'open',# to block that meeting date in the calendar
        }
        meeting_id = meeting_obj.create(cr, uid, meeting_vals)
        vals['meeting_id'] = meeting_id
        return super(project_task_work,self).create(cr, uid, vals, *args, **kwargs)

When I check fields with dev mode I can see my personal field "meeting_id". But when I create a new task.work, I've no new meeting and there are no message on log file. Did I make a mistake?

Avatar
Discard
2 Answers
8
Best Answer

Everytime you make a modification to server or addons's python code, you have to restart your instance in order to re-load the codebase including your modifications.

On a side note, if you modify an XML view, you'll have to update the module (-u mymodule in launching args) to take your modifications into account.

And finally, if you modify some JS code, a simple refresh in your browser will do the trick.

2 Comments
Avatar
Discard
Avatar
Quentin De Paoli (qdp)
-

and when modifying a RML file directly, just calling the report again do the trick

Avatar
vita soa
-

Bjr Anto, j'ai modifié un bout de code python dans openerp 7, mais quand je restart tous mes serveurs postgres, python, le code n'est pas modifié dans openerp. Pour info je suis en Win 7

1
Avatar
Bonnet Denis
Best Answer

I found the problem after 1 day of work. I have to restart openERP. This is the second time this solution resolve a problem and it's written nowhere in the doc. If this tips can help someone else: If nothing work : RESTART

2 Comments
Avatar
Discard
Avatar
Vo Minh Thu
-

The question would have some sense if it was asking about some hot code reloading feature. But it is otherwise quite abvious that code changes are not visible to a running program.

Avatar
Bonnet Denis
-

yes but in a web environment i use to just refresh my page to update my script(php,javascript...)