Skip to Content
Menu
This question has been flagged
3 Replies
2837 Views

how do I use the automation function in odoo studio to create a record?

Avatar
Discard
Best Answer

Here's a simple example that creates reordering rules for a product.  This is for Odoo 16 and earlier, see the other answer for Odoo 17.

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).

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 expressionrecord.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.

Create reordering rules

Create analytic accounts for sales orders

Avatar
Discard

Chris - how can you achieve the same in v17?

The "Data to Write" tab has been removed, so it all has to be done in Python code (and I'm not a Python programmer). If I have time I'll try to update my answer. I'm not sure this example is needed for Odoo 17, because Replenishment creates these records automatically.

Best Answer

In Odoo Studio, you can use the automation function to create a record by setting up an Automated Action. Here’s a step-by-step guide on how to do it:

1. Go to Automations:
You can access this from anywhere within Studio.

2. Create an Automated Action
: Define the following elements:

  • Model: Select the model where the automated action should be applied.

  • Trigger: Define when the automated action should be applied. You can choose from six triggers: On Creation, On Update, On Creation & Update, On Deletion, Based on Form Modification, and Based on Timed Condition.

  • Apply on: Define on which records of the model the automated action should be applied.

  • Action: Determine what the automated action should do. In your case, you want to create a record, so you would choose the “Create a new Record” action. Then, you’ll need to specify the model where the new record should be created and set the values for the fields of the new record.

Please note that the exact steps might vary depending on your specific requirements and the version of Odoo you’re using.


Avatar
Discard
Best Answer

Hi,Here are the steps to create record automation using Odoo 17 Studio:

  1. Navigate to the "Automation" section in Odoo 17 Studio.
  2. Click on the "Create" button to create a new automation.
  3. In the "Create Automation" form, enter a name for the automation and select the "Record Rules" option.
  4. In the "Record Rules" tab, select the model for which you want to create the automation.
  5. Define the conditions for the automation by setting up the "Trigger Condition" and "Domain" fields. The "Trigger Condition" field allows you to specify when the automation should be triggered, while the "Domain" field allows you to define the records that the automation should apply to.
  6. In the "Actions" tab, click on the "Add an action" button.
  7. Select the "Create a new record" option from the list of available actions.
  8. In the "Create a new record" form, select the model for the new record and fill in the required fields.
  9. Save the new record automation.

Once you have created the record automation, it will be triggered based on the conditions you defined, and a new record will be created according to the action you specified.

These steps are specified for Version 17, there will be changes in previous versions of Odoo

For further information, you can refer to Odoo's official document
https://www.odoo.com/documentation/17.0/applications/productivity/studio/automated_actions.html


Hope it helps

Avatar
Discard