[FIX] project, issue: change user_id + date_start

project.task: use an onchange to update date_start when changing user_id.
Indeed date_start is automatically updated in the create / write. Without
the onchange, this may lead to errors related to date_start being greater
then date_end.

project.issue: code in create and write now takes into account date_open
values given to the method and avoid erasing them.
In issue however the onchange is not added. Indeed the date_open and
date_closed fields are not visible in the view. They are automatically
computed and used to compute statistics.
This commit is contained in:
Thibault Delavallée 2015-11-23 16:31:40 +01:00
parent af6305722f
commit 8fa7318178
2 changed files with 4 additions and 3 deletions

View File

@ -396,6 +396,7 @@
<field name="project_id" domain="[('state','not in', ('close', 'cancelled'))]" on_change="onchange_project(project_id)" context="{'default_use_tasks':1}"/>
<field name="user_id"
options='{"no_open": True}'
on_change="onchange_user_id(user_id, context)"
context="{'default_groups_ref': ['base.group_user', 'base.group_partner_manager', 'project.group_project_user']}"/>
<field name="reviewer_id"
options='{"no_open": True}'

View File

@ -303,7 +303,7 @@ class project_issue(osv.Model):
context = dict(context or {})
if vals.get('project_id') and not context.get('default_project_id'):
context['default_project_id'] = vals.get('project_id')
if vals.get('user_id'):
if vals.get('user_id') and not vals.get('date_open'):
vals['date_open'] = fields.datetime.now()
if 'stage_id' in vals:
vals.update(self.onchange_stage_id(cr, uid, None, vals.get('stage_id'), context=context)['value'])
@ -319,8 +319,8 @@ class project_issue(osv.Model):
vals['date_last_stage_update'] = fields.datetime.now()
if 'kanban_state' not in vals:
vals['kanban_state'] = 'normal'
# user_id change: update date_start
if vals.get('user_id'):
# user_id change: update date_open
if vals.get('user_id') and 'date_open' not in vals:
vals['date_open'] = fields.datetime.now()
return super(project_issue, self).write(cr, uid, ids, vals, context)