From 9d77062ddbbda1a43128b9619ac9677f84319fba Mon Sep 17 00:00:00 2001 From: JF Aubert Date: Fri, 21 Aug 2020 10:23:49 +0000 Subject: [PATCH] [FIX] mrp: hide m2m serials column in draft or if components are not tracked On production order view, dot not show the Serial Numbers column when in draft or when no component tracked by serial number closes odoo/odoo#56889 X-original-commit: 4fc8374ee4470a05b27216999e341418e72f28ea Signed-off-by: Arnold Moyaux --- addons/mrp/models/mrp_production.py | 6 ++++++ addons/mrp/views/mrp_production_views.xml | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) 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 @@