From 9ce0fcba50bbb057e713c339df6cac277b198efa Mon Sep 17 00:00:00 2001 From: "Pieter Claeys (clpi)" Date: Thu, 23 Feb 2023 12:13:29 +0000 Subject: [PATCH] [IMP] mrp: production view updates Add the scheduled production end date to the form and list views and reorder the filter list. Also fixes a bug where the end date of an MO without any workorders was set incorrectly upon closing the MO. Task: 2479234 (nr 5) Community PR: https://github.com/odoo/odoo/pull/114315 Enterprise PR: https://github.com/odoo/enterprise/pull/37764 Part-of: odoo/odoo#114315 --- addons/mrp/models/mrp_production.py | 7 ++++--- addons/mrp/views/mrp_production_views.xml | 15 +++++++++------ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/addons/mrp/models/mrp_production.py b/addons/mrp/models/mrp_production.py index 0ea7685d0ea..cf0c8270020 100644 --- a/addons/mrp/models/mrp_production.py +++ b/addons/mrp/models/mrp_production.py @@ -689,15 +689,16 @@ class MrpProduction(models.Model): late_stock_moves = self.env['stock.move'].search([('delay_alert_date', operator, value)]) return ['|', ('move_raw_ids', 'in', late_stock_moves.ids), ('move_finished_ids', 'in', late_stock_moves.ids)] - @api.depends('company_id', 'date_start', 'is_planned', 'product_id') + @api.depends('company_id', 'date_start', 'is_planned', 'product_id', 'workorder_ids.duration_expected') def _compute_date_finished(self): for production in self: - if not production.date_start or production.is_planned: + if not production.date_start or production.is_planned or production.state == 'done': continue days_delay = production.bom_id.produce_delay date_finished = production.date_start + relativedelta(days=days_delay) if date_finished == production.date_start: - date_finished = date_finished + relativedelta(hours=1) + workorder_expected_duration = sum(self.workorder_ids.mapped('duration_expected')) + date_finished = date_finished + relativedelta(minutes=workorder_expected_duration or 60) production.date_finished = date_finished @api.depends('company_id', 'bom_id', 'product_id', 'product_qty', 'product_uom_id', 'location_src_id', 'date_start') diff --git a/addons/mrp/views/mrp_production_views.xml b/addons/mrp/views/mrp_production_views.xml index 5fc387a7c8d..e7d9665525b 100644 --- a/addons/mrp/views/mrp_production_views.xml +++ b/addons/mrp/views/mrp_production_views.xml @@ -24,6 +24,7 @@ + @@ -262,13 +263,13 @@ + - @@ -447,6 +448,8 @@ attrs="{'invisible': ['|', ('state', 'in', ('done', 'cancel')), ('date_deadline', '=', False)]}" decoration-danger="date_deadline and date_deadline < current_date" decoration-bf="date_deadline and date_deadline < current_date"/> + + @@ -555,19 +558,19 @@ help="Manufacturing Orders which are in confirmed state."/> + + - - - - + + -