34 lines
1.3 KiB
Python
34 lines
1.3 KiB
Python
from odoo import models, fields, api
|
|
|
|
class MrpProduction(models.Model):
|
|
_inherit = 'mrp.production'
|
|
|
|
hide_quality_check_button = fields.Boolean(compute='_compute_hide_quality_check_button')
|
|
|
|
@api.depends_context('uid')
|
|
def _compute_hide_quality_check_button(self):
|
|
for record in self:
|
|
record.hide_quality_check_button = not self.env.user.allowed_quality_checks
|
|
|
|
def action_confirm(self):
|
|
res = super(MrpProduction, self.sudo()).action_confirm()
|
|
if isinstance(res, dict) and res.get('type') == 'ir.actions.act_window':
|
|
context = res.get('context') or {}
|
|
if isinstance(context, str):
|
|
pass
|
|
else:
|
|
res['context'] = {**context, 'bypass_user_restriction': True}
|
|
return res
|
|
|
|
def button_mark_done(self):
|
|
res = super(MrpProduction, self.sudo()).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):
|
|
return super(MrpProduction, self.with_context(bypass_user_restriction=True)).create(vals_list)
|