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) => {