From 8fdfd4a77ca040ed5de92a36f0828552539c36c1 Mon Sep 17 00:00:00 2001 From: Swapnesh Shah Date: Wed, 20 Mar 2019 18:02:32 +0000 Subject: [PATCH] [FIX] project: Fill date_last_stage_update when needed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before this commit, the date_last_stage_update field in fill everytime at task creation. This does not make sense if ther is no project linked to the task or if there is no stages associated to the project/task. This commit populates the date_last_stage_update field only when needed. So, we can now have newly created task without date_last_stage_update filled. closes odoo/odoo#31999 Signed-off-by: Jérome Maes (jem) --- addons/project/models/project.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/project/models/project.py b/addons/project/models/project.py index a17ea4cfabe..411f56aac63 100644 --- a/addons/project/models/project.py +++ b/addons/project/models/project.py @@ -478,7 +478,6 @@ class Task(models.Model): date_assign = fields.Datetime(string='Assigning Date', index=True, copy=False, readonly=True) date_deadline = fields.Date(string='Deadline', index=True, copy=False, track_visibility='onchange') date_last_stage_update = fields.Datetime(string='Last Stage Update', - default=fields.Datetime.now, index=True, copy=False, readonly=True) @@ -696,9 +695,10 @@ class Task(models.Model): # user_id change: update date_assign if vals.get('user_id'): vals['date_assign'] = fields.Datetime.now() - # Stage change: Update date_end if folded stage + # Stage change: Update date_end if folded stage and date_last_stage_update if vals.get('stage_id'): vals.update(self.update_date_end(vals['stage_id'])) + vals['date_last_stage_update'] = fields.Datetime.now() task = super(Task, self.with_context(context)).create(vals) return task