From 53324c44de72f5c38f8f6bd6a4b6adf4b52d3f21 Mon Sep 17 00:00:00 2001 From: "Stefan-Calin Crainiciuc (stcc)" Date: Thu, 23 Feb 2023 14:53:47 +0000 Subject: [PATCH] [REV] mrp: create productivity line before modifying workorder Reverts https://github.com/odoo/odoo/pull/110666 because of breaking behaviour introduced in https://github.com/odoo/enterprise/pull/35696 - Install quality_mrp_workorder - Manufacturing > Config > Create 2 workcenters: WC1 and WC2 - Products > New Product > Name: P, type: Storable, Routes: Manufacture - Manufacturing > BoMs > Create > Product: P, Operations Tab, add 2 lines: - 1. operation: OP1, Work Center: WC1, Save - 2. operation: OP2, Work center: WC2, Save - Manual Save BoM, don't exit - Components Tab, unlock column Consumend in Operation, add 2 lines: - 1. Product: P1, Create and edit > type: Storable - 2. Product: P2, Create and edit > type: Storable - Both lines, quantity: 2. - Each line, Consumed in operations: OP1 and OP2 - Save and exit - Operations > Manufacturing orders > New > Product: P, Quantity: 2 > Confirm - Workorder Tab > open first line tablet view: Quantity = 2.00/2.00 Units > Validate - open second line tablet view: Quantity = 0.00/2.00 Units (!) closes odoo/odoo#113574 Issue: The recommended quantity should also be 2.00/2.00 X-original-commit: 67774c967b587a660be032712b7a2369ed7abc3a Related: odoo/enterprise#37500 Signed-off-by: Tiffany Chang Signed-off-by: Stefan-Calin Crainiciuc (stcc) --- addons/mrp/models/mrp_workorder.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/mrp/models/mrp_workorder.py b/addons/mrp/models/mrp_workorder.py index 929a0ad80dc..364b3e277a4 100644 --- a/addons/mrp/models/mrp_workorder.py +++ b/addons/mrp/models/mrp_workorder.py @@ -615,16 +615,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(),