As standard, any Odoo user who has access to products can set them as ‘archived’ (which means they are not available to use).
- Of course, you can easily stop users deleting products by limiting which groups of users can take that action, but it won’t prevent users from archiving products.
For this, we will use Automated Actions as shown below.
You need to be in ‘developer’ mode and then navigate to Settings / Technical / (Automation) / Automated Actions and click ‘Create’.
Model: Product Template
Trigger Condition: On Creation & Update
Before Update Domain: Active records
Apply On: Active is not set
Action to Do: Execute Python Code
if not env.user.has_group('sales_team.group_sale_manager'):
raise Warning('You cannot archive products')
You can choose any user access group for this.
sales_team.group_sale_manager is the Sales Manager group
This is the result when a user click on the ‘Archive’ button:
This will also block other ways of archiving products:
You could add more business rules to this, for example to limit which products or product types can be archived.