Skip to Content
Menu
This question has been flagged

Hi, I would like to execute certain functions I've written in a model, A upon if a new record is added, B if any fields of any existing records are modified, C if a specific field of any existing records are modified.

I've found that I can use the @api.onchange for C, but I'm having trouble with cases A and B. It seems easy to implement via Odoo Studio and Automation Actions, to set the trigger for record creation and record change for A and B respectively, before selecting code and writing the snippet of python code I wish to execute.

However, I don't wish to depend on Odoo studio, and wish to write a standalone module for this that can be exported and used by others without having to configure the automated action manually. I don't mind using Odoo Studio if I'm able to export it with nothing more needed to be done on the end user's part when they install the module. I'm currently trying to write the action through automated actions, exporting it and going through the files to see how it is written, if exporting the actions are possible. Unfortunately, I found the documentation for coding your own actions to be rather sparse, or perhaps I missed it, so perhaps reverse engineering is the way to go.

Is there a way I can set triggers that execute using the python model files and the XML configuration files in a custom module, executing code when triggered, while also being able to retrieve current and old values through 'self'?

Avatar
Discard
Related Posts Replies Views Activity
10
Apr 20
15231
3
Apr 24
1349
0
Nov 23
850
1
Sep 23
1340
1
Feb 21
3790