Use Automated Actions to stop users archiving products

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:

List View for Products / Action

You could add more business rules to this, for example to limit which products or product types can be archived.

2 thoughts on “Use Automated Actions to stop users archiving products

Leave a Reply to Priscila Cancel reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s