From 439ba7d94552efa231bed11db4f45464bec006a4 Mon Sep 17 00:00:00 2001 From: yhu-odoo Date: Mon, 9 Jan 2023 15:46:09 +0000 Subject: [PATCH] [FIX] mrp: show manual consumption when workorder not enabled In 49bc9aac201136e684cac9d84df97f80d217afa4, when we need operation_id when we check if manual_consumption is readonly or not, so groups="mrp.group_mrp_routings" was added for manual_consumption. As a result, we can't see manual_consumption on BOM when workorder is not enabled. To fix, we add a computed field as a workaround. Task-3116125 Part-of: odoo/odoo#113538 --- addons/mrp/models/mrp_bom.py | 7 +++++++ addons/mrp/views/mrp_bom_views.xml | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/addons/mrp/models/mrp_bom.py b/addons/mrp/models/mrp_bom.py index f0d19c7f7b8..397803a7bb5 100644 --- a/addons/mrp/models/mrp_bom.py +++ b/addons/mrp/models/mrp_bom.py @@ -407,6 +407,8 @@ class MrpBomLine(models.Model): 'Manual Consumption', default=False, compute='_compute_manual_consumption', store=True, copy=True, help="When activated, then the registration of consumption for that component is recorded manually exclusively.\n" "If not activated, and any of the components consumption is edited manually on the manufacturing order, Odoo assumes manual consumption also.") + manual_consumption_readonly = fields.Boolean( + 'Manual Consumption Readonly', compute='_compute_manual_consumption_readonly') _sql_constraints = [ ('bom_qty_zero', 'CHECK (product_qty>=0)', 'All product quantities must be greater or equal to 0.\n' @@ -418,6 +420,11 @@ class MrpBomLine(models.Model): def _compute_manual_consumption(self): self.filtered(lambda m: m.tracking != 'none' or m.operation_id).manual_consumption = True + @api.depends('tracking', 'operation_id') + def _compute_manual_consumption_readonly(self): + for line in self: + line.manual_consumption_readonly = (line.tracking != 'none' or line.operation_id) + @api.depends('product_id', 'bom_id') def _compute_child_bom_id(self): products = self.product_id diff --git a/addons/mrp/views/mrp_bom_views.xml b/addons/mrp/views/mrp_bom_views.xml index 972efe8a048..0b60938a0d1 100644 --- a/addons/mrp/views/mrp_bom_views.xml +++ b/addons/mrp/views/mrp_bom_views.xml @@ -98,8 +98,8 @@ - - + +