fix: use sudo() for mrp production actions to robustly bypass access restrictions
This commit is contained in:
parent
f31a64e0d3
commit
3b6bbd4250
@ -11,20 +11,17 @@ class MrpProduction(models.Model):
|
|||||||
record.hide_quality_check_button = not self.env.user.allowed_quality_checks
|
record.hide_quality_check_button = not self.env.user.allowed_quality_checks
|
||||||
|
|
||||||
def action_confirm(self):
|
def action_confirm(self):
|
||||||
res = super(MrpProduction, self.with_context(bypass_user_restriction=True)).action_confirm()
|
res = super(MrpProduction, self.sudo()).action_confirm()
|
||||||
if isinstance(res, dict) and res.get('type') == 'ir.actions.act_window':
|
if isinstance(res, dict) and res.get('type') == 'ir.actions.act_window':
|
||||||
context = res.get('context') or {}
|
context = res.get('context') or {}
|
||||||
if isinstance(context, str):
|
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
|
pass
|
||||||
else:
|
else:
|
||||||
res['context'] = {**context, 'bypass_user_restriction': True}
|
res['context'] = {**context, 'bypass_user_restriction': True}
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def button_mark_done(self):
|
def button_mark_done(self):
|
||||||
res = super(MrpProduction, self.with_context(bypass_user_restriction=True)).button_mark_done()
|
res = super(MrpProduction, self.sudo()).button_mark_done()
|
||||||
if isinstance(res, dict) and res.get('type') == 'ir.actions.act_window':
|
if isinstance(res, dict) and res.get('type') == 'ir.actions.act_window':
|
||||||
context = res.get('context') or {}
|
context = res.get('context') or {}
|
||||||
if not isinstance(context, str):
|
if not isinstance(context, str):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user