[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) <whe@odoo.com>
Signed-off-by: Stefan-Calin Crainiciuc (stcc) <stcc@odoo.com>
This commit is contained in:
Stefan-Calin Crainiciuc (stcc)
2023-01-31 12:56:17 +01:00
parent 790ad0e961
commit 74c684d541
+5 -4
View File
@@ -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(),