diff --git a/addons/mrp/models/mrp_production.py b/addons/mrp/models/mrp_production.py index 8998ded9725..4b1703e4da5 100644 --- a/addons/mrp/models/mrp_production.py +++ b/addons/mrp/models/mrp_production.py @@ -255,6 +255,7 @@ class MrpProduction(models.Model): ('available', 'Available'), ('expected', 'Expected'), ('late', 'Late')], compute='_compute_components_availability') + show_lot_ids = fields.Boolean('Display the serial number shortcut on the moves', compute='_compute_show_lot_ids') @api.depends('product_id', 'bom_id', 'company_id') def _compute_allowed_product_ids(self): @@ -518,6 +519,11 @@ class MrpProduction(models.Model): for order in self: order.show_lock = self.env.user.has_group('mrp.group_locked_by_default') and order.id is not False and order.state not in {'cancel', 'draft'} + @api.depends('state','move_raw_ids') + def _compute_show_lot_ids(self): + for order in self: + order.show_lot_ids = order.state != 'draft' and any(m.product_id.tracking == 'serial' for m in order.move_raw_ids) + _sql_constraints = [ ('name_uniq', 'unique(name, company_id)', 'Reference must be unique per Company!'), ('qty_positive', 'check (product_qty > 0)', 'The quantity to produce must be positive!'), diff --git a/addons/mrp/views/mrp_production_views.xml b/addons/mrp/views/mrp_production_views.xml index fe65b74e6d6..b05c6970e55 100644 --- a/addons/mrp/views/mrp_production_views.xml +++ b/addons/mrp/views/mrp_production_views.xml @@ -142,6 +142,7 @@ + @@ -271,7 +272,7 @@