from odoo import api, SUPERUSER_ID def post_init_hook(env): """ Remove 'quality.group_quality_user' from implied_ids of specific manufacturing groups that cannot be targeted via XML IDs (e.g., 'MPS User'). """ # We use a new env with superuser rights env = api.Environment(env.cr, SUPERUSER_ID, {}) # Identify the Quality User group quality_user_group = env.ref('quality.group_quality_user', raise_if_not_found=False) if not quality_user_group: return # List of groups to decouple by name if their XML ID is missing or tricky # "MPS User" is the primary target found during debugging target_group_names = ['MPS User'] for group_name in target_group_names: # Search for the group by name # We also check category to be safer, generally 'Manufacturing' group = env['res.groups'].search([('name', '=', group_name)], limit=1) if group: # Check if it implies quality user if quality_user_group in group.implied_ids: # Remove the implication group.write({'implied_ids': [(3, quality_user_group.id)]}) # Also perform a broader search for any group in 'Manufacturing' category # that implies Quality User, just to be thorough, excluding the main Manager group # which generally SHOULD have it (or maybe not? The request is strict). # For now, let's stick to the specific target to avoid over-optimizing and breaking things.