hr_timesheet/7.0 rev n°56 generates issues in crm_todo module

Bug #1246409 reported by Antoine Heskia
16
This bug affects 3 people
Affects Status Importance Assigned to Milestone
HR - Timesheet Management
New
Undecided
Unassigned

Bug Description

OpenERP version 7.0-20131024-232504
hr_timeheet/7.0 revision n°56 (and 57)

When updated hr_timesheet/7.0 modules to latest version, a new issue appeared in crm_todo module :
In Sales ==> Opportunities, open/edit an opportunity. Go to "Tasks" tab and click on "add an item". Fill-in the task and save the opportunity.
The following OpenERP server error pops up :

OpenERP Server Error

Client Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.7/openerp/addons/web/http.py", line 204, in dispatch
    response["result"] = method(self, **self.params)
  File "/usr/lib/pymodules/python2.7/openerp/addons/web/controllers/main.py", line 1128, in call_kw
    return self._call_kw(req, model, method, args, kwargs)
  File "/usr/lib/pymodules/python2.7/openerp/addons/web/controllers/main.py", line 1120, in _call_kw
    return getattr(req.session.model(model), method)(*args, **kwargs)
  File "/usr/lib/pymodules/python2.7/openerp/addons/web/session.py", line 42, in proxy
    result = self.proxy.execute_kw(self.session._db, self.session._uid, self.session._password, self.model, method, args, kw)
  File "/usr/lib/pymodules/python2.7/openerp/addons/web/session.py", line 30, in proxy_method
    result = self.session.send(self.service_name, method, *args)
  File "/usr/lib/pymodules/python2.7/openerp/addons/web/session.py", line 103, in send
    raise xmlrpclib.Fault(openerp.tools.ustr(e), formatted_info)

Server Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.7/openerp/addons/web/session.py", line 89, in send
    return openerp.netsvc.dispatch_rpc(service_name, method, args)
  File "/usr/lib/pymodules/python2.7/openerp/netsvc.py", line 292, in dispatch_rpc
    result = ExportService.getService(service_name).dispatch(method, params)
  File "/usr/lib/pymodules/python2.7/openerp/service/web_services.py", line 626, in dispatch
    res = fn(db, uid, *params)
  File "/usr/lib/pymodules/python2.7/openerp/osv/osv.py", line 188, in execute_kw
    return self.execute(db, uid, obj, method, *args, **kw or {})
  File "/usr/lib/pymodules/python2.7/openerp/osv/osv.py", line 131, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/usr/lib/pymodules/python2.7/openerp/osv/osv.py", line 197, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/usr/lib/pymodules/python2.7/openerp/osv/osv.py", line 185, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/usr/lib/pymodules/python2.7/openerp/addons/crm/crm_lead.py", line 932, in write
    return super(crm_lead, self).write(cr, uid, ids, vals, context=context)
  File "/usr/lib/pymodules/python2.7/openerp/addons/mail/mail_thread.py", line 275, in write
    result = super(mail_thread, self).write(cr, uid, ids, values, context=context)
  File "/usr/lib/pymodules/python2.7/openerp/osv/orm.py", line 4278, in write
    self.pool.get(object)._store_set_values(cr, user, todo, fields_to_recompute, context)
  File "/opt/openerp/addons/hr_timesheet/7.0/timesheet_task/project_task.py", line 62, in _store_set_values
    project.write({'parent_id': project.parent_id.id})
AttributeError: 'NoneType' object has no attribute 'id'

Here is what I can see in /var/log/openerp/openerp-server.log :
2013-10-30 16:57:10,924 5028 INFO Comexans werkzeug: 10.1.101.16 - - [30/Oct/2013 16:57:10] "POST /web/dataset/call_kw HTTP/1.1" 200 -
2013-10-30 16:57:10,926 5028 INFO Comexans werkzeug: 10.1.101.16 - - [30/Oct/2013 16:57:10] "POST /web/dataset/call_kw HTTP/1.1" 200 -
2013-10-30 16:57:10,997 5028 INFO Comexans werkzeug: 10.1.101.16 - - [30/Oct/2013 16:57:10] "POST /web/dataset/call_kw HTTP/1.1" 200 -
2013-10-30 16:57:11,066 5028 ERROR Comexans openerp.osv.osv: Uncaught exception
Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.7/openerp/osv/osv.py", line 131, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/usr/lib/pymodules/python2.7/openerp/osv/osv.py", line 197, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/usr/lib/pymodules/python2.7/openerp/osv/osv.py", line 185, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/usr/lib/pymodules/python2.7/openerp/addons/crm/crm_lead.py", line 932, in write
    return super(crm_lead, self).write(cr, uid, ids, vals, context=context)
  File "/usr/lib/pymodules/python2.7/openerp/addons/mail/mail_thread.py", line 275, in write
    result = super(mail_thread, self).write(cr, uid, ids, values, context=context)
  File "/usr/lib/pymodules/python2.7/openerp/osv/orm.py", line 4278, in write
    self.pool.get(object)._store_set_values(cr, user, todo, fields_to_recompute, context)
  File "/opt/openerp/addons/hr_timesheet/7.0/timesheet_task/project_task.py", line 62, in _store_set_values
    project.write({'parent_id': project.parent_id.id})
AttributeError: 'NoneType' object has no attribute 'id'
2013-10-30 16:57:11,069 5028 ERROR Comexans openerp.netsvc: 'NoneType' object has no attribute 'id'
Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.7/openerp/netsvc.py", line 292, in dispatch_rpc
    result = ExportService.getService(service_name).dispatch(method, params)
  File "/usr/lib/pymodules/python2.7/openerp/service/web_services.py", line 626, in dispatch
    res = fn(db, uid, *params)
  File "/usr/lib/pymodules/python2.7/openerp/osv/osv.py", line 188, in execute_kw
    return self.execute(db, uid, obj, method, *args, **kw or {})
  File "/usr/lib/pymodules/python2.7/openerp/osv/osv.py", line 131, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/usr/lib/pymodules/python2.7/openerp/osv/osv.py", line 197, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/usr/lib/pymodules/python2.7/openerp/osv/osv.py", line 185, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/usr/lib/pymodules/python2.7/openerp/addons/crm/crm_lead.py", line 932, in write
    return super(crm_lead, self).write(cr, uid, ids, vals, context=context)
  File "/usr/lib/pymodules/python2.7/openerp/addons/mail/mail_thread.py", line 275, in write
    result = super(mail_thread, self).write(cr, uid, ids, values, context=context)
  File "/usr/lib/pymodules/python2.7/openerp/osv/orm.py", line 4278, in write
    self.pool.get(object)._store_set_values(cr, user, todo, fields_to_recompute, context)
  File "/opt/openerp/addons/hr_timesheet/7.0/timesheet_task/project_task.py", line 62, in _store_set_values
    project.write({'parent_id': project.parent_id.id})
AttributeError: 'NoneType' object has no attribute 'id'
2013-10-30 16:57:11,071 5028 INFO Comexans werkzeug: 10.1.101.16 - - [30/Oct/2013 16:57:11] "POST /web/dataset/call_kw HTTP/1.1" 200 -

If I revert hr_timesheet/7.0 to revision n°55, the bug disappears.

Do you have any idea ?

Thanks for your support.

Revision history for this message
Antoine Heskia (antoine-heskia) wrote :

Hi again,

 Following my previous post, I can see that the issue is related to hr_timesheet/7.0/timesheet_task/project_task.py
Since revision 56 some new lines have been added at line 54 :

    def _store_set_values(self, cr, uid, ids, fields, context=None):
        # Hack to avoid redefining most of function fields of project.project model
        # This is mainly due to the fact that orm _store_set_values use direct access to database.
        # So when modifiy aa line the _store_set_values as it uses cursor directly to update tasks
        # project triggers on task are not called
        res = super(ProjectTask, self)._store_set_values(cr, uid, ids, fields, context=context)
        for row in self.browse(cr, SUPERUSER_ID, ids, context=context):
            project = row.project_id
            project.write({'parent_id': project.parent_id.id})
        return res

The crm_todo module (introduces GTD method in CRM) and use project_gtd to achieve this.
So with this crm_todo module, it is possible to create (GTD) tasks in an opportunity (within the CRM). As it is a task it might inherit of the same methods ans this might be the reason why timesheet_task module is invoked. This task is not related to a prent project but to a CRM opportunity and this might be the reason why we have this bug : project.parent_id.id is NoneType (it does not exist). So a test to verify that project.parent_id.id is not NoneType brefore calling project.write shall be performed.
I am sorry I do not have any knowledge in Python, so I can not fix it myself... Can somebody fix that ?

Thanks for your help...

Revision history for this message
Qasim (qasim) wrote :

Second this report.

Revision history for this message
Richard Stubbings (richard-stubbings) wrote :

Im having the same issue tasks are not possible in CRM opportunities once analytic timesheet in task (timesheet_task) is installed.

Version 7.0-20140403-230522
analytic timesheet in task 7.0.0.2.1
CRM 7.0.1.0

Please fix this ASAP as the only work around right now is to run 2 separate db´s which is USELESS!!

Changed in hr-timesheet:
status: New → Confirmed
status: Confirmed → New
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.