Odoo Help


1 Answer

OKay I can answer this question for you. First of all, when making a CRON job in odoo, and making an XML record for it, the first thing to note in the .py file is that the def should start with _ (_). so your

def get_active_srs(selfa):

would become:

def _get_active_srs(selfa):

Now this function cannot be used on a button type='object' and tells the scheduler that it is in fact a CRON job.

For the xml record, we need to create a file like this in order to include that CRON to run at the desired time:

<?xml version="1.0"?>
  <data noupdate="1">
    <record id="ir_cron_custom" model="ir.cron">
      <field name="name">YOUR CRON NAM</field>
      <field name="active" eval="True"/>
      <field name="user_id" ref="base.user_root" />
      <field name="interval_number">1</field>
      <field name="interval_type">days</field>
      <field name="numbercall">-1</field>
      <field name="model">sale.order</field>
      <field name="function">_get_active_srs</field>
      <field name="doall">1</field>
      <field name="nextcall" >2017-06-26 21:07:59</field>
      <field name="args" eval="'[]'" />

Now we can see that the CRON is set for every day, its active, and it is going to run the _get_active_srs function.

Instead of days you can place hours, minutes, months even years.

Hope this answers your question,

Riste Kabranov, Python/Odoo Dev

@Nebiz IT Dooel Skopje

Ask a Question
Keep Informed
1 follower(s)
About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now