Skip to content

Commit

Permalink
[FIX] project, issue: change user_id + date_start
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tde-banana-odoo committed Nov 23, 2015
1 parent af63057 commit 8fa7318
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions addons/project/project_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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}'
Expand Down
6 changes: 3 additions & 3 deletions addons/project_issue/project_issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def create(self, cr, uid, vals, context=None):
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'])
Expand All @@ -319,8 +319,8 @@ def write(self, cr, uid, ids, vals, context=None):
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)
Expand Down

0 comments on commit 8fa7318

Please sign in to comment.