This question has been flagged

Hi all,

In v16.4 you could configure a server action/automated action to create a new record in another model

https://www.odoo.com/documentation/master/applications/productivity/studio/automated_actions.html#create-a-new-record

Within the automated action you could add data to write (you could add field data to be saved in the target model.)


In v17 i can't find that functionality anymore (the data to write) although it is still in the documentation.

How should we proceed? 

Should we select python code and do it via python code?

or is there another thing i should know ?


thx for sharing your info!


kr

roeland

Avatar
Discard

Yes, the functionality has been lost in v17 as per this change in GitHub: https://github.com/odoo/odoo/pull/114352

You can create a record but you can't specify any fields. It's possible to do some of it in Python, but ironically this so-called simplification has made it more difficult.

https://www.odoo.com/forum/help-1/limitations-in-automation-rules-odoo-17-244783

a feature which encourages to learn Python or?

Author Best Answer

Hi all,


I think I have found the solution:

Create a server action with the type "Execute code".

Then use the following code:


 env['targetmodelname'].create({

         'field1':record.name,                          =>insert python expression

         'field2':25,                                          =>insert value (integer, float)

         'field3':record.id                                =>insert python expression (linked field)

​'field4':"characters"                          =>insert value (char)

 })

 

env['targetmodelname'].create({
         'field1':record.name,
         'field2':25,
         'field3':record.id,
	 'field4':"characters"
 })
Avatar
Discard

Indeed, this is possible, but so-called "simplification" has made it more difficult.

Best Answer

Hi,

In odoo17 you can create another record by using the automation rule by following the below steps

1)Open the Automation rule from settings ->Technical ->Automation -> Automation Rule


2) Create a new record by adding the fields


You can change the field values according to your needs

3) click on the Add an Action button from the Action To Do page Then a pop-up will appear. from that select Create Record option


Then you can fill in the values in the action details area.


Hope it helps


Avatar
Discard