From f31a64e0d30b7e6a3183aba87c30d8b7a9d927db Mon Sep 17 00:00:00 2001 From: Suherdy Yacob Date: Mon, 16 Feb 2026 17:11:53 +0700 Subject: [PATCH] fix: explicit context propagation to wizards from mrp production actions --- models/mrp_production.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/models/mrp_production.py b/models/mrp_production.py index 8bda73f..a0e74da 100644 --- a/models/mrp_production.py +++ b/models/mrp_production.py @@ -11,10 +11,25 @@ class MrpProduction(models.Model): record.hide_quality_check_button = not self.env.user.allowed_quality_checks def action_confirm(self): - return super(MrpProduction, self.with_context(bypass_user_restriction=True)).action_confirm() + res = super(MrpProduction, self.with_context(bypass_user_restriction=True)).action_confirm() + if isinstance(res, dict) and res.get('type') == 'ir.actions.act_window': + context = res.get('context') or {} + if isinstance(context, str): + # If context is a string (rare but possible in old Odoo, less likely in 19), handle or ignore. + # In Odoo 19 it's likely a dict or python string representation. + # Safer to just assume dict for now given standard patterns or let it be if complex. + pass + else: + res['context'] = {**context, 'bypass_user_restriction': True} + return res def button_mark_done(self): - return super(MrpProduction, self.with_context(bypass_user_restriction=True)).button_mark_done() + res = super(MrpProduction, self.with_context(bypass_user_restriction=True)).button_mark_done() + if isinstance(res, dict) and res.get('type') == 'ir.actions.act_window': + context = res.get('context') or {} + if not isinstance(context, str): + res['context'] = {**context, 'bypass_user_restriction': True} + return res @api.model_create_multi def create(self, vals_list):