Back to Top

Creating Automated Server Actions in Odoo

Updated 10 April 2017

Odoo-Code-Snippet-banner

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

        Searching for an experienced
        Odoo Company ?
        Find out More
        • 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 :
        1. ‘on_create’ = ‘On Creation’
        2. ‘on_write’ = ‘On Update’
        3. ‘on_create_or_write’ = ‘On Creation & Update’
        4. ‘on_unlink’ = ‘On Deletion’
        5. ‘on_change’ = ‘Based on Form Modification’
        6. ‘on_time’ = ‘Based on Timed Condition’
      • server_action_ids : define server action ids
<?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>

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


8 comments

  • jaleen sheen
    • Ashish Singh (Moderator)
  • mesby
    • Ashish (Moderator)
  • Federico Leoni
    • Ashish (Moderator)
      • virk
        • Ashish Singh (Moderator)
  • Back to Top

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home