[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) <arm@odoo.com>
This commit is contained in:
Martin Maes
2023-03-17 19:21:54 +01:00
parent a4e441e885
commit 35eb9ef155
2 changed files with 6 additions and 4 deletions
+4 -1
View File
@@ -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):
+2 -3
View File
@@ -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) => {