Use Automated Actions to create Reordering Rules

Reordering Rules define minimum and maximum planned stock levels so that Odoo can propose what needs to be re-ordered. If you want to use this approach, it’s important to have Reordering Rules setup for all the affected products (e.g. all components).

It’s possible to use Automated Actions to setup Reordering Rules automatically at the time you create a product.

You need to know that:

  1. the reordering rules are stored in the Minimum Inventory Rule model (stock.warehouse.orderpoint)
    • primary key is product
  2. we want to create one record for each product on the product.product table (don’t use the product template table product.template)

Start by enabling Developer mode and navigating to Settings / Technical / Automated Actions:

If you cannot find this option, you may need to install the module “Automated Action Rules”.

Click on CREATE and the following screen is displayed:

Action Name: Enter a description (e.g. Set reorder Point)

Model: Product (product.product)

Trigger Condition: On Creation

Apply on: Product Type = ‘product’ (because this does not apply to services or consumable items). See notes below on how to add this by clicking on “EDIT DOMAIN.

Action To Do: Create a New Record

Create / Write Target Model: Minimum Inventory Rule (stock.warehouse.orderpoint)

Data to Write

Minimum Quantity(stock.warehouse.orderpoint)Value0
Maximum Quantity(stock.warehouse.orderpoint)Value10
Product(stock.warehouse.orderpoint)Python expression record.id

Of course you can enter whatever values you want for minimum and maximum quantity in the first two lines, but the third line (for the product) must be exactly as shown above (and yes, a Python expression can be as simple as this).

It’s also possible to have different sets of minimum and maximum quantity for different types of product, though if your rules are more complex it may be better handled by doing development.

Note: in Odoo 14, there is an additional field “Trigger”, but this defaults to “Auto”, so there is no need to set it (unless you want replenishment to be manual).

You can also create this Automated Action as a Server Action to setup Reordering Rules for existing items.

Edit domain

This is easy to do. After clicking on “EDIT DOMAIN” (screenshot above), click on “Add Filter”

Click on that green button “Add Filter” and then you can select the fields you are going to use. We’ll select Product Type from the dropdown:

Only “Storable Products” can have Reordering Rules, so we will select that value (this is easy to do because it is a Selection Field).

Notice that it shows you the code that has been generated. You can directly edit this if you feel confident, and you can also copy it for use elsewhere.

Click on SAVE

You can add more complex domains if required. This is where you could specify that this rule applies to a specified product category (or several categories).

3 thoughts on “Use Automated Actions to create Reordering Rules

  1. Very good tip and works fine for very small setup, problem arises when we have lot of products (like 50K+) and 5-6+ locations/warehouses so it ends up with 50K x 5 reordering rules, i.e. one for each product and for each location. that not only have a big and unnecessary data but also slows down the system. To overcome this problem we have developed a module that provide a default reordering rule on the fly when need for each product for each location, off course if user has not created a reordering rule for the product for that location/warehouse.

    Like

    1. I don’t think that is a problem with this Automated Action. It only creates a single Reordering Rule per product.

      In later versions of Odoo, reordering rules are created automatically by Odoo.

      Like

      1. No, sorry i didn’t meant that, i didn’t highlight the issue/problem in automated action, its great, i tried to highlight the inherited/built-in problem in Odoo that if we have lot of products and multiple warehouses then we have to have lot of data just for reorder rules with default values for each product in each warehouse, now suppose we have 50K products and at some day customer want to create a new warehouse/location then we have to create 50K new reorder rules for each products. So to solve this problem we have created a module.

        Like

Leave a comment