c2c-oerpscenario team mailing list archive
-
c2c-oerpscenario team
-
Mailing list archive
-
Message #29581
[Bug 803979] Re: project_timesheet: inherited project.task write def updates all work entries
Hi Amit,
the problem is that if you write a task (for example in another module
by inheritance or by the XML-RPC API) it will iterate all work_ids of
the task object given instead of only iterating changed work_ids from
vals...no problem as long no confirmed timesheets are involved. If there
is only one task work with a confirmed timesheet you will run into an
error with the current code and can not write other task works which
have been changed.
Anyway why should you always iterate over ALL existing work_ids of a
task object by default? :-)
It is actually documented in the code above (if 'work_ids' in vals: my
opinion how it should be, else: iteration of all corresponding work_ids)
Hope my explanation helps!
--
You received this bug notification because you are a member of C2C
OERPScenario, which is subscribed to the OpenERP Project Group.
https://bugs.launchpad.net/bugs/803979
Title:
project_timesheet: inherited project.task write def updates all work
entries
Status in OpenERP Modules (addons):
Incomplete
Bug description:
It is not possible to write a specific task work (in an module which
calls project.task write and wants to trigger an update of analytic
timesheet)
It will always run into an exception when work entries of a task are
already in a confirmed state because the for loop tries to update ALL
work entries instead of specific ones.
I compared the mechanism of the task view and rebuilt the vals
structure and added an if condition...probably the else could be
eliminated but this should be evaluated before :-)
def write(self, cr, uid, ids,vals,context=None):
if context is None:
context = {}
if vals.get('project_id',False) or vals.get('name',False):
vals_line = {}
hr_anlytic_timesheet = self.pool.get('hr.analytic.timesheet')
task_obj_l = self.browse(cr, uid, ids, context=context)
if vals.get('project_id',False):
project_obj = self.pool.get('project.project').browse(cr, uid, vals['project_id'], context=context)
acc_id = project_obj.analytic_account_id.id
if 'work_ids' in vals:
for work in vals['work_ids']:
task_work = self.pool.get('project.task.work').browse(cr, uid, [work[1]])[0]
if not task_work.hr_analytic_timesheet_id:
continue
line_id = task_work.hr_analytic_timesheet_id
if vals.get('project_id',False):
vals_line['account_id'] = acc_id
if vals.get('name',False):
vals_line['name'] = '%s: %s' % (tools.ustr(vals['name']), tools.ustr(task_work.name) or '/')
hr_anlytic_timesheet.write(cr, uid, [line_id.id], vals_line, {})
else:
for task_obj in task_obj_l:
if len(task_obj.work_ids):
for task_work in task_obj.work_ids:
if not task_work.hr_analytic_timesheet_id:
continue
line_id = task_work.hr_analytic_timesheet_id.id
if vals.get('project_id',False):
vals_line['account_id'] = acc_id
if vals.get('name',False):
vals_line['name'] = '%s: %s' % (tools.ustr(vals['name']), tools.ustr(task_work.name) or '/')
hr_anlytic_timesheet.write(cr, uid, [line_id], vals_line, {})
return super(task,self).write(cr, uid, ids, vals, context)
Hope you were able to follow :-)
Best regards,
Wolfgang
To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-addons/+bug/803979/+subscriptions
References