From b4a1b87fb669ac2fceeda909f36363c0c76308a3 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Wed, 4 Sep 2019 13:09:54 +0000 Subject: [PATCH] [FIX] mrp: domain on field final_lot_id in mrp.production.work.order.form Steps to reproduce the bug: Let's consider two storable products P1 and P2 where P1 is tracked by serial number - Create a BOM B for P1 where P2 is a component - Create a serial numberv SN for P1 with no quantity - Create a MO M1 for P1 and click on button "Produce" - In the view MRP Product Produce, SN is selectable in the field lot_id - Now change B and set a routing on it - Create a new MO M2 for P1 and click on produce - At least one WO has been created, click on the first one Bug: - SN is not selectable in the field final_lot_id The domain set on the field final_lot_id: "['|', '&', ('product_id', '=', product_id), ('product_id.tracking', '!=', 'serial'), ('use_next_on_work_order_id', '=', id)]" didn't allow to chose SN. With this fix, it's now possible to chose SN on the first WO created for M2 opw:2059745 closes odoo/odoo#36425 Signed-off-by: Simon Goffin (sig) --- addons/mrp/models/mrp_workorder.py | 8 ++++++++ addons/mrp/views/mrp_workorder_views.xml | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/addons/mrp/models/mrp_workorder.py b/addons/mrp/models/mrp_workorder.py index 92bfa990996..1c6d87a29c7 100644 --- a/addons/mrp/models/mrp_workorder.py +++ b/addons/mrp/models/mrp_workorder.py @@ -63,6 +63,9 @@ class MrpWorkorder(models.Model): is_produced = fields.Boolean(string="Has Been Produced", compute='_compute_is_produced') + is_first_wo = fields.Boolean(string="Is the first WO to produce", + compute='_compute_is_first_wo') + state = fields.Selection([ ('pending', 'Pending'), ('ready', 'Ready'), @@ -140,6 +143,11 @@ class MrpWorkorder(models.Model): rounding = self.production_id.product_uom_id.rounding self.is_produced = float_compare(self.qty_produced, self.production_id.product_qty, precision_rounding=rounding) >= 0 + @api.multi + def _compute_is_first_wo(self): + for wo in self: + wo.is_first_wo = (wo.production_id.workorder_ids[0] == wo) + @api.one @api.depends('time_ids.duration', 'qty_produced') def _compute_duration(self): diff --git a/addons/mrp/views/mrp_workorder_views.xml b/addons/mrp/views/mrp_workorder_views.xml index a01e3c700d3..f7499ab677d 100644 --- a/addons/mrp/views/mrp_workorder_views.xml +++ b/addons/mrp/views/mrp_workorder_views.xml @@ -141,7 +141,8 @@ - + +