From e292c3fb53fadba4dbcf7e27ddd1a7f0f2fe926d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Voet=20=28ryv=29?= Date: Mon, 16 Nov 2020 17:10:31 +0000 Subject: [PATCH] [REF] mrp: consumption of workorder become related Avoid duplicate information in DB. task-2373638 --- addons/mrp/models/mrp_production.py | 1 - addons/mrp/models/mrp_workorder.py | 7 +------ addons/mrp/views/mrp_production_views.xml | 2 +- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/addons/mrp/models/mrp_production.py b/addons/mrp/models/mrp_production.py index fb662491db0..db4fbec72a6 100644 --- a/addons/mrp/models/mrp_production.py +++ b/addons/mrp/models/mrp_production.py @@ -798,7 +798,6 @@ class MrpProduction(models.Model): 'product_uom_id': production.product_uom_id.id, 'operation_id': operation.id, 'state': 'pending', - 'consumption': production.consumption, }] production.workorder_ids = [(5, 0)] + [(0, 0, value) for value in workorders_values] for workorder in production.workorder_ids: diff --git a/addons/mrp/models/mrp_workorder.py b/addons/mrp/models/mrp_workorder.py index 03749019b04..74f6694748c 100644 --- a/addons/mrp/models/mrp_workorder.py +++ b/addons/mrp/models/mrp_workorder.py @@ -140,12 +140,7 @@ class MrpWorkorder(models.Model): production_date = fields.Datetime('Production Date', related='production_id.date_planned_start', store=True, readonly=False) json_popover = fields.Char('Popover Data JSON', compute='_compute_json_popover') show_json_popover = fields.Boolean('Show Popover?', compute='_compute_json_popover') - consumption = fields.Selection([ - ('strict', 'Strict'), - ('warning', 'Warning'), - ('flexible', 'Flexible')], - required=True, - ) + consumption = fields.Selection(related='production_id.consumption') @api.depends('production_state', 'date_planned_start', 'date_planned_finished') def _compute_json_popover(self): diff --git a/addons/mrp/views/mrp_production_views.xml b/addons/mrp/views/mrp_production_views.xml index b4ffe552d45..b694a3c4df0 100644 --- a/addons/mrp/views/mrp_production_views.xml +++ b/addons/mrp/views/mrp_production_views.xml @@ -282,7 +282,7 @@ - +