From 74c684d541b73f089cf49948a009b1125769b334 Mon Sep 17 00:00:00 2001 From: "Stefan-Calin Crainiciuc (stcc)" Date: Mon, 30 Jan 2023 10:04:49 +0000 Subject: [PATCH] [FIX] mrp: create productivity line before modifying workorder Necessary for odoo/enterprise#35867 Steps to reproduce: - Install Quality, Manufacturing - Manufacturing > Settings > Enable Work Orders - Manufacturing Orders > Create order for Table > Confirm > Work orders tab > Open Tablet View - Get to step 'Please encode the table legs lot number' - Change the quantity to produce - Pause > Continue Issue: The quantity to produce is reset to 4/4 Units. Solution: Check if the workorder is paused before applying `qty_done` changes. opw-3032052 closes odoo/odoo#111402 X-original-commit: 4acb1781c5aedc011ba00054285f64963aa0dacc Related: odoo/enterprise#36491 Signed-off-by: William Henrotin (whe) Signed-off-by: Stefan-Calin Crainiciuc (stcc) --- addons/mrp/models/mrp_workorder.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/addons/mrp/models/mrp_workorder.py b/addons/mrp/models/mrp_workorder.py index a442c8836d3..a4fe11e2fa9 100644 --- a/addons/mrp/models/mrp_workorder.py +++ b/addons/mrp/models/mrp_workorder.py @@ -613,15 +613,16 @@ class MrpWorkorder(models.Model): if self.state in ('done', 'cancel'): return True + if self._should_start_timer(): + self.env['mrp.workcenter.productivity'].create( + self._prepare_timeline_vals(self.duration, datetime.now()) + ) + if self.product_tracking == 'serial': self.qty_producing = 1.0 elif self.qty_producing == 0: self.qty_producing = self.qty_remaining - if self._should_start_timer(): - self.env['mrp.workcenter.productivity'].create( - self._prepare_timeline_vals(self.duration, datetime.now()) - ) if self.production_id.state != 'progress': self.production_id.write({ 'date_start': datetime.now(),