from odoo import models, fields, api class StockPicking(models.Model): _inherit = 'stock.picking' <<<<<<< HEAD restrict_quality_check_button = fields.Boolean(compute='_compute_restrict_quality_check_button') @api.depends_context('uid') def _compute_restrict_quality_check_button(self): user = self.env.user for picking in self: # Check if user is in restricted groups (Inventory User or MPS User/Manager) # MPS user usually relates to Manufacturing Manager or User, but user specifically asked for "MPS User". # Since there is no widespread "MPS User" group in standard, we assume it falls under Manufacturing. # However, we will check strictly for the groups mentioned in the request: # Inventory User: stock.group_stock_user # Manufacturing User: mrp.group_mrp_user # MPS User: mrp.group_mrp_manager (often implies MPS access) is_inventory_user = user.has_group('stock.group_stock_user') is_mrp_user = user.has_group('mrp.group_mrp_user') is_mrp_manager = user.has_group('mrp.group_mrp_manager') # User is possibly restricted if they have one of these basic roles is_restricted_role = is_inventory_user or is_mrp_user or is_mrp_manager # But we must NOT hide if they are Quality Manager or System Admin is_quality_manager = user.has_group('quality.group_quality_manager') is_system = user.has_group('base.group_system') if is_restricted_role and not (is_quality_manager or is_system): picking.restrict_quality_check_button = True else: picking.restrict_quality_check_button = False ======= hide_quality_check_button = fields.Boolean(compute='_compute_hide_quality_check_button') @api.depends('picking_type_id') @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 >>>>>>> 4a049d1 (feat: Implement user-specific control for quality check button visibility on manufacturing orders and inventory transfers via a new `allowed_quality_checks` field on users.)