access_restriction_by_user/models/mrp_production.py

16 lines
612 B
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('product_id')
@api.depends_context('uid')
def _compute_hide_quality_check_button(self):
for record in self:
# Logic: Hide logic is inverse of "is allowed"
# If allowed_quality_checks is True, hide = False
# If allowed_quality_checks is False, hide = True
record.hide_quality_check_button = not self.env.user.allowed_quality_checks