access_restriction_by_user/models/stock_picking.py

18 lines
662 B
Python

from odoo import models, fields, api
class StockPicking(models.Model):
_inherit = 'stock.picking'
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):
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()