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
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
Odoo 14
There is a small change to the syntax in Odoo 14:
if not env.user.has_group('sales_team.group_sale_manager'):
raise UserError('You cannot archive products')
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.
Hi, the code not work in my database !!
The error say “Odoo Server Error”.
Any idea?
LikeLike
You need to look at the details of the error and it should show you the problem.
LikeLike