From ca2975383c0135cbcc158b4a9d59873420a280ce Mon Sep 17 00:00:00 2001
From: William Henrotin <whe@odoo.com>
Date: Fri, 26 Jun 2020 14:07:21 +0000
Subject: [PATCH] [FIX] mrp: redirect to workorder list from consumption wizard

If the consumption wizard is triggered in a workorder (via 'Mark As Done
And Close MO'). We would like the confirm button redirect to the
workorder list view afterwards.

Task : 2278147

X-original-commit: 55e2a4d16d3a56b8f509d2d67a344c53d62474b6
---
 addons/mrp/wizard/mrp_consumption_warning.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/addons/mrp/wizard/mrp_consumption_warning.py b/addons/mrp/wizard/mrp_consumption_warning.py
index db0404a9eabf..022d88dbecf3 100644
--- a/addons/mrp/wizard/mrp_consumption_warning.py
+++ b/addons/mrp/wizard/mrp_consumption_warning.py
@@ -29,6 +29,9 @@ class MrpConsumptionWarning(models.TransientModel):
             wizard.consumption = "strict" in consumption_map and "strict" or "warning" in consumption_map and "warning" or "flexible"
 
     def action_confirm(self):
+        if self.env.context.get('from_workorder'):
+            if self.env.context.get('active_model') == 'mrp_workorder':
+                return self.env['mrp.workorder'].browse(self.env.context.get('active_id')).do_finish()
         return self.mrp_production_ids.with_context(skip_consumption=True).button_mark_done()
 
     def action_cancel(self):
-- 
GitLab