Creating Automated Server Actions in Odoo
Automated server actions automatically trigger actions for various screens.
Odoo provide very simple way to create automated server actions.
Steps to create automated server actions in Odoo ,
- Install “Automated Action Rules” module at Odoo. This module enable feature to create automated server actions.
- Create a method using python which will trigger using server action,
@api.model
def automated_action_method(self):
active_ids = self._context.get('active_ids')
for active_id in active_ids:
self.env['model.name'].browse(active_id).name = 'name'
return True
- Create a server action using xml which will trigger using automated actions.
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="0">
<record id="id_server_action" model="ir.actions.server">
<field name="name">Odoo Server Action</field>
<field name="model_id" ref="product.model_model_model"/>
<field name="state">code</field>
<field name="code">action = env["model.model"].automated_action_method()</field>
</record>
</data>
</openerp>
- Create a automated server action using xml,
- There have few attributes which are used for automated server actions,
- name : Automated Server Action Name
- active : place ‘1’ to active or place ‘0’ to inactive automated server action
- model_id : Format to define model_id
module.model_model_name- Here module is Module where automated server action is created
- In model_model_name : “model_” is prefix and “model_name” is model name where automated server action will be triggered.
- kind :
- ‘on_create’ = ‘On Creation’
- ‘on_write’ = ‘On Update’
- ‘on_create_or_write’ = ‘On Creation & Update’
- ‘on_unlink’ = ‘On Deletion’
- ‘on_change’ = ‘Based on Form Modification’
- ‘on_time’ = ‘Based on Timed Condition’
- server_action_ids : define server action ids
- There have few attributes which are used for automated server actions,
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="0">
<record id="id_automated_server_action" model="base.action.rule">
<field name="name">Odoo Automated Server Action</field>
<field name="model_id" ref="module.model_model_name"/>
<field name="active">1</field>
<field name="kind">on_write</field>
<field name="server_action_ids" eval="[(6,0,[ref('id_server_action')])]"/>
</record>
</data>
</openerp>
View Comments (8)
Comment or Ask a Question
Quick Links