feat: Add bypass_user_restriction context to various action methods across multiple models and optimize the allowed_quality_checks field.

This commit is contained in:
Suherdy Yacob 2026-01-21 15:00:41 +07:00
parent 4a049d124e
commit b9b6e549c0
8 changed files with 22 additions and 0 deletions

View File

@ -13,3 +13,9 @@ class MrpProduction(models.Model):
# If allowed_quality_checks is True, hide = False # If allowed_quality_checks is True, hide = False
# If allowed_quality_checks is False, hide = True # If allowed_quality_checks is False, hide = True
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):
return super(MrpProduction, self.with_context(bypass_user_restriction=True)).action_confirm()
def button_mark_done(self):
return super(MrpProduction, self.with_context(bypass_user_restriction=True)).button_mark_done()

View File

@ -51,5 +51,6 @@ class ResUsers(models.Model):
allowed_quality_checks = fields.Boolean( allowed_quality_checks = fields.Boolean(
string="Is Allowed todo Quality Checks?", string="Is Allowed todo Quality Checks?",
default=False, default=False,
prefetch=False,
help="If checked, this user can see the Quality Checks button on Manufacturing Orders." help="If checked, this user can see the Quality Checks button on Manufacturing Orders."
) )

View File

@ -93,3 +93,9 @@ class ApprovalRequest(models.Model):
if allowed_category_ids: if allowed_category_ids:
domain = expression.AND([domain or [], [('category_id', 'in', allowed_category_ids)]]) domain = expression.AND([domain or [], [('category_id', 'in', allowed_category_ids)]])
return super()._search(domain, offset=offset, limit=limit, order=order) return super()._search(domain, offset=offset, limit=limit, order=order)
def action_confirm(self):
return super(ApprovalRequest, self.with_context(bypass_user_restriction=True)).action_confirm()
def action_approve(self, approver=None):
return super(ApprovalRequest, self.with_context(bypass_user_restriction=True)).action_approve(approver=approver)

View File

@ -5,3 +5,6 @@ class SaleOrder(models.Model):
def action_confirm(self): def action_confirm(self):
return super(SaleOrder, self.with_context(bypass_user_restriction=True)).action_confirm() return super(SaleOrder, self.with_context(bypass_user_restriction=True)).action_confirm()
def _action_confirm(self):
return super(SaleOrder, self.with_context(bypass_user_restriction=True))._action_confirm()

View File

@ -10,3 +10,9 @@ class StockPicking(models.Model):
def _compute_hide_quality_check_button(self): def _compute_hide_quality_check_button(self):
for record in self: for record in self:
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):
return super(StockPicking, self.with_context(bypass_user_restriction=True)).action_confirm()
def button_validate(self):
return super(StockPicking, self.with_context(bypass_user_restriction=True)).button_validate()