Showing posts with label Scheduler. Show all posts
Showing posts with label Scheduler. Show all posts

Friday, 20 April 2012

How to create Scheduler in OpenERP

How to create Scheduler in  OpenERP . ( ir.cron )
                                                                                                        Nayi Pinakin
                                                                                                        Trainee OpenERP ,
                                                                                                        Gandhinagar . (Jan 2012 )
                                                                                                        nayi_pinakin@yahoo.in
Here are Steps you have to follow :

Step 1 :
          In view file simply write as under
          <record model="ir.cron" id="resource_panelty_cron">
            <field name="name">Resource Panelty Count</field>
            <field name="interval_number">1</field>
            <field name="interval_type">minute</field>
            <field name="numbercall">-1</field>
            <field eval="False" name="doall"/>
            <field eval="'lib.register'" name="model"/>
            <field eval="'compute_penalty'" name="function"/>  # call the function in .py file
            <field eval="'()'" name="args"/>
        </record>

Step 2 :
        you can also directly create your Scheduler :
         like ,
         1.       First you simply go setting - > configuration -> scheduler -> scheduler_action



      2.  Now create new Scheduler  here interval number and interval unit important



   3.  Now , in object simply write your table name and in Method write your .py file method 
        which you want to call at every repeated time.


       

 Description : 


"scheduler_id" : is a unique xml record id
"scheduler_name" : any desirable name
"active" :  True or False determines whether the scheduler is active or not..
"user_id" : refers the user who owns the scheduler
"interval_number" : number of times the scheduler is to be called based on the "interval_type"

"interval_type" 
: it can be days, hours, minututes etc
"numbercall" : Number of time the function is called. negative number indicates no limit
"doall" : booelan field. A 'True' enables it to execute missed occurences as soon as the server is restarts

 "model" : Name of object whose function will be called when this scheduler will run. e.g. 'res.partener'
"function" : Name of the method to be called on the object when this scheduler is executed.
 "args" : Arguments to be passed to the method. e.g. (uid,)