[project_timesheet] has reference to unassigned variable 'result'

Bug #653032 reported by James Jesudason
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Canonical OpenERP
Fix Released
High
Dhruti Shastri(OpenERP)
Odoo Addons (MOVED TO GITHUB)
Fix Released
Undecided
Dhruti Shastri(OpenERP)

Bug Description

The project_timesheet module references a dictionary called 'result', which will be unassigned in certain circumstances. If a user_id is not passed into the write method e.g. when the number of hours are changed on a timesheet line. In the standard screens the error does not occur because the whole record is passed into the write method. However, we're working on a module to simplify timesheet entry, and that exposes the bug in the code.

bzr revno: 4977

Related branches

James Jesudason (jamesj)
summary: - project_timesheet has reference to unassigned variable 'result'
+ [project_timesheet] has reference to unassigned variable 'result'
James Jesudason (jamesj)
Changed in canonical-openerp:
status: New → Confirmed
importance: Undecided → High
milestone: none → timesheets-pilot
Changed in canonical-openerp:
assignee: nobody → DHS(OpenERP) (dhs-openerp)
Revision history for this message
Dhruti Shastri(OpenERP) (dhs-openerp) wrote :

Hello Jesudasan,

    I agree that when the write() method is called without the 'user_id' it can cause an error. But if its coming from GTK it will always have a 'user_id' as it's a required field. I have found a solution for this, IMHO taking the 'uid' (logged user) in place of 'user_id' (assigned user) doesn't seem to be feasible. So would you please check the attached patch and notify us ?

Thanks.

Changed in openobject-addons:
assignee: nobody → DHS(OpenERP) (dhs-openerp)
Revision history for this message
James Jesudason (jamesj) wrote :

Hi,

The custom view that I'm using is an editable tree-view that includes the work hours and user_id. If you change the work hours field on a record and click 'Save', then the GTK client only sends the following in the vals dictionary:
{'unit_amount': 3.0}

Note: user_id is not passed through, and the error is raised. I can provide a copy of the view if you need to do more testing.

I've checked your patch that initialises the result dictionary at the start of the write() method, and that works fine. Your amendment seems correct, and is probably what the original author intended.

Thanks

Revision history for this message
Dhruti Shastri(OpenERP) (dhs-openerp) wrote :

Hello James,

   I agree with you that if you have a customized view it'll definitely not have the 'user_id' so for that either you need to override the write() method in the module where you have the customized view or you can just simply use the attached patch.

Thanks.

Revision history for this message
James Jesudason (jamesj) wrote :

Hi,

Actually the custom view does have the user_id in, but the GTK client does not send that in the dictionary when I just change the work hours. I've attached a copy of the view for you to look at.

I still think the that field result needs to be initialised in the trunk code - there shouldn't be any logic paths that allow a user to get to an uninitialised variable.

James

Revision history for this message
Anup(SerpentCS) (anup-serpent) wrote :

Hello James,

   Yes I have seen your customized view. It was having user_id but it was not passing it when write() was being called.
  It has been fixed by revision 4199 <email address hidden>

Thanks.

Changed in openobject-addons:
milestone: none → 6.0
status: New → Fix Released
Revision history for this message
James Jesudason (jamesj) wrote :

Excellent, thanks

Changed in canonical-openerp:
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

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