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."/>
+
+
-
-
-
-
+
+
-