Skip to Content
Menu
This question has been flagged
1 Reply
8274 Views

we need a cronjob that should only be executed once per day at the same time:


<record forcecreate="True" id="cron_create_dailydone" model="ir.cron">
<field name="name">DailyCreates</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_id" ref="model_x_dummy_dummy"/>
<field name="code">model.cron_create_dailies()</field>
<field name="args">()</field>
<field name="state">code</field>
<field name="active">True</field>
<field name="nextcall" >2018-11-01 03:10:59</field>
</record>

When Odoo was shut down and restarts after longer Downtime this Cronjob will be triggered.
I thought doall = False would prevent this.

we do not want that this job runs after starting odoo. It should only run at 3:10 each day.
If odoo is down at this time the cronjob should not be executed later.

can this be achieved with cron-settings? Or do i have to check this within python-logic of the cronjob?


Avatar
Discard
Best Answer

Hi !

Try this below code (Read and Changes as per your need)



 
<record id="ir_cron_module_update_notification" model="ir.cron">
<field name="name">Publisher: Update Notification</field>
<field name="model_id" ref="model_publisher_warranty_contract"/>
<field name="state">code</field>
<field name="code">model.update_notification(None)</field>
<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="nextcall" eval="(DateTime.now() + timedelta(days=1)).strftime('%Y-%m-%d 03:10:59')" />
<field eval="False" name="doall" />
<field name="priority">1000</field>
</record>

Avatar
Discard

I hope this is not the correct answer, this will work only on installation time.

Number of call(number call) is -1. it will repeat the job every one day at 3 AM. Okay

Author

it does not work. i created a new cronjob like described. Turned off odoo over night. now restarted odoo in the morning. and the cronjob was triggered short after restarting odoo (now at the wrong time in the morning)