From 35eb9ef155b32a214ab4e3871f73e019a7bc04e5 Mon Sep 17 00:00:00 2001 From: Martin Maes Date: Fri, 10 Mar 2023 09:23:55 +0000 Subject: [PATCH] [FIX] mrp: timer wrong values on list view The value of the timer was wrong when timesheeting with multiple employees at the same time. The problem was that the compute duration already takes the current timesheets into account. So the problem was that we added some time that was already in the duration task id : 3216277 closes odoo/odoo#114901 Related: odoo/enterprise#38007 Signed-off-by: Arnold Moyaux (arm) --- addons/mrp/models/mrp_workorder.py | 5 ++++- addons/mrp/static/src/widgets/timer.js | 5 ++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/addons/mrp/models/mrp_workorder.py b/addons/mrp/models/mrp_workorder.py index 07fd99a99b0..3b380d41921 100644 --- a/addons/mrp/models/mrp_workorder.py +++ b/addons/mrp/models/mrp_workorder.py @@ -872,6 +872,10 @@ class MrpWorkorder(models.Model): duration += (datetime.now() - time.date_start).total_seconds() / 60 return duration + def get_duration(self): + self.ensure_one() + return sum(self.time_ids.mapped('duration')) + self.get_working_duration() + def action_mark_as_done(self): for wo in self: if wo.working_state == 'blocked': @@ -885,7 +889,6 @@ class MrpWorkorder(models.Model): for wo in self: if wo.working_state == 'blocked': raise UserError(_('Some workorders require another workorder to be completed first')) - for wo in self: wo.button_start() def action_mass_pause(self): diff --git a/addons/mrp/static/src/widgets/timer.js b/addons/mrp/static/src/widgets/timer.js index b327bc25f97..c65101586bc 100644 --- a/addons/mrp/static/src/widgets/timer.js +++ b/addons/mrp/static/src/widgets/timer.js @@ -104,12 +104,11 @@ class MrpTimerField extends Component { !this.props.record.model.useSampleModel && this.props.record.data.state == "progress" ) { - const additionalDuration = await this.orm.call( + this.duration = await this.orm.call( "mrp.workorder", - "get_working_duration", + "get_duration", [this.props.record.resId] ); - this.duration += additionalDuration; } }); onWillUpdateProps((nextProps) => {