Odoo Help


How to call a scheduled task (cron) using the new API v8?

Justin Lessard
on 9/15/15, 9:19 AM 2,772 views

I'm trying to run a scheduled task on Odoo v8. The task is started correctly without any problem, but the cron method is called using the legacy API.

That means I need to always pass the cr, uid, context vars when calling a method. It also means I don't have access to certains var such as self.env, self,._ds, ...

How does someone create a scheduled task and call it with the new API (v8)?

Here is the cron record

<record id="ir_cron_generate_periodic_invoices" model="ir.cron">
<field name="name">Generate Periodic Invoices from Contract</field>
<field eval="True" name="active"/>
<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="doall" eval="False"/>
<field name="model">account.analytic.account</field>
<field name="function">_cron_periodic_create_invoice</field>
<field name="args">()</field>

And here is the object

class account_analytic_account(models.Model):
_inherit = "account.analytic.account"

def _cron_periodic_create_invoice(self,cr, uid, context=None):

def _periodic_create_invoice(self):
# Do something here ...

Akhil P Sivan

--Akhil P Sivan--

| 5 4 7
Kochi, India
--Akhil P Sivan--

Interested in exploring Odoo both technically & functionality wise.

email-id : akhilpsivan01@gmail.com

Akhil P Sivan
On 10/27/15, 1:55 AM


You may try like this:

class account_analytic_account(models.Model):
_inherit = "account.analytic.account"

def _cron_periodic_create_invoice(self):

def _periodic_create_invoice(self):
# Do something here ...

Hope this helps

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

Question tools

2 follower(s)


Asked: 9/15/15, 9:19 AM
Seen: 2772 times
Last updated: 10/27/15, 3:08 AM