how do I use the automation function in odoo studio to create a record?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project
- MRP
This question has been flagged
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:
- the reordering rules are stored in the Minimum Inventory Rule model (stock.warehouse.orderpoint)
- primary key is product
- 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) | Value | 0 |
Maximum Quantity | (stock.warehouse.orderpoint) | Value | 10 |
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.
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.
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.
Hi,Here are the steps to create record automation using Odoo 17 Studio:
- Navigate to the "Automation" section in Odoo 17 Studio.
- Click on the "Create" button to create a new automation.
- In the "Create Automation" form, enter a name for the automation and select the "Record Rules" option.
- In the "Record Rules" tab, select the model for which you want to create the automation.
- 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.
- In the "Actions" tab, click on the "Add an action" button.
- Select the "Create a new record" option from the list of available actions.
- In the "Create a new record" form, select the model for the new record and fill in the required fields.
- 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
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up