Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Automated action in odoo

1,291 views

Published on

Automated actions can be used to automatically trigger actions based on a time condition. We can use them to automatically perform some operation on records that meet certain criteria and reach time condition.Schedulers are automated actions that run automatically over a time period and can do a lot of things. They execute actions without manual interaction and makes background job very easy: For this simply insert a record to the ir.cron table and Odoo will execute it as defined.

Published in: Business
  • Be the first to comment

  • Be the first to like this

Automated action in odoo

  1. 1. www.cybrosys.com Automated Action In Odoo
  2. 2. INTRODUCTION  Automated actions can be used to automatically trigger actions based on time conditions. We can use them to automatically perform some operation on records that meet certain criteria and reach a predefined time. Schedulers are automated actions that run automatically over a period of time and can do a lot of things. They execute actions without manual interaction and makes the background jobs very easy. To set up a schedule you just have to insert a record to 'ir.cron' table and Odoo will execute it as you define it.
  3. 3. 1. Creating the model and fields  The first step is to create a model (if you don’t have one yet) and to create some fields on this model: class ModelName(models.Model): _name = 'model.name' fields_name = fields.Char(string=" ") def method_name(self): "Your code here"
  4. 4. 2. Creating the views  Once you have created the database, now it is time to create the view 3. Creating the automated action <?xml version="1.0" ?> <odoo> <data noupdate="1"> <record id="backup_scheduler" model="ir.cron"> <field name="function">schedule_backup</field> <field name="interval_type">work_days</field> <field name="name">Backup scheduler</field> <field name="numbercall">-1</field> <field name="priority">5</field> <field name="doall">False</field> <field name="active">False</field> <field name="interval_number">1</field> <field name="model">db.backup</field> </record> </data> </odoo>
  5. 5.  An important thing to note with automated actions is that they always should be defined within a 'noupdate' field. Because this part shouldn’t be updated when you update your module.  Here in above example <data noupdate="1">  Indicate that all code within this tag shouldn’t be updated when you update your module. <record id="unique_name" model="ir.cron">  The id is a unique identifier for Odoo to know what record is linked to which id. The model “ir.cron” is the model specifically made by Odoo for all automated actions. This model contains all automated actions and always it should be specified.
  6. 6. <field name="name">Name </field>  Indicate the name of the fields. <field name="active" eval="True" />  Boolean value indicating whether the ‘cron’ job is active or not. <field name="user_id" ref="base.user_root"/>  This user id is referring to a specific user, in most cases this will be ‘base.user_root’. <field name="interval_number">1</field>
  7. 7.  Number of times the scheduler is to be called based on the “interval_type” <field name="interval_type">days</field>  Interval Unit. It should be one value for the list: minutes, hours, days, weeks, months. <field name="numbercall">-1</field>  An integer value specifying how many times the job is executed. A negative value means no limit.
  8. 8. <field name="doall">1</field>  A Boolean value indicating whether missed occurrences should be executed when the server restart <field name="nextcall" >2016-12-31 23:59:59</field> <!-- notice the date/time format -->  Next planned execution date for this job. <field name="model" eval="'model.name '" />  This field specifies on which model the automated action should be called. <field name="function" eval="'method_name '" />  Name of the method to be called when this job is processed. <field name="args" eval="" />  The arguments to be passed to the method. <field name="priority" eval="5" />  The priority of the job, as an integer: 0 means higher priority, 10 means lower priority.
  9. 9. Refer this link for more: https://www.cybrosys.com/blog/automated-action-in-odoo
  10. 10. Thank You ! Cybrosys Technologies Pvt. Ltd. Neospace, Kinfra Techno Park, Kakkancherry, Calicut University P.O. Calicut Kerala, India - 673635. Cybrosys Ltd 15, ST Antonys Road, Forest Gate, London England, E79QA. Cybrosys Technologies Pvt. Ltd. 1st Floor, Thapasya Building, Infopark, Kakkanad, Kochi, Kerala, India-682030.

×