Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
6 Trả lời
18534 Lượt xem

Hello guys,


I want to run a corn job every begging of the year.

I try this :

<record id="ir_cron_yearly_transfert" model="ir.cron">
<field name="name">Holiday: transfert yearly balance</field>
<field name="model_id" ref="hr_holidays_custom.model_hr_contract"/>
<field name="state">code</field>
<field name="code">model.cron_yearly_transfert()</field>
<field name="interval_type">months</field>
<field name="numbercall">-1</field>
<field name="interval_number">12</field>
</record>

but the Next Execution Date shows 08/06/2020 16:52:40

How can I solve this?
Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hello,

After creating your cron job you need to set first time manually next execution date then it will done automatically next year if interval_type=months and interval_number=12  base on your next execution date.

Thanks

Haresh Chavda


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Try adding this to your configuration to schedule the job from Jan 1, 2021 midnight onwards.

<field name="nextcall">2021-01-01 00:00:00</field>
Ảnh đại diện
Huỷ bỏ
Tác giả

Thanks, but I don't like to put a static year I want it dynamic

The static year will get used only for the first run. As soon as the first run is done, it will get updated with Jan 1 of the following year. You can try it with a shorter interval to see how it works.

The interval of 12 months will take care of the rescheduling.

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 10 23
2647
9
thg 6 23
13770
2
thg 1 22
4365
2
thg 12 21
8537
1
thg 10 21
6194