Skip to content

[12.0][FIX] company_today: Execute every 15 min, remove doall #265

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: 12.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions company_today/data/ir_cron.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,19 @@ SPDX-License-Identifier: AGPL-3.0-or-later
<field name="model_id" ref="model_res_company" />
<field name="code">model.cron_update_today()</field>
<field name="active" eval="True" />
<field name="interval_number">1</field>
<field name="interval_number">15</field>
<field name="interval_type">minutes</field>
<!-- Round to nearest 15 min -->
<field
name="nextcall"
eval="datetime.min
+ round(
(datetime.now() - datetime.min + timedelta(minutes=15))
/ timedelta(minutes=15)
)
* timedelta(minutes=15)"
/>
<field name="numbercall">-1</field>
<field name="doall">1</field>
<field name="doall">0</field>
</record>
</odoo>
4 changes: 3 additions & 1 deletion company_today/models/res_company.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ class Company(models.Model):
@api.model
def cron_update_today(self):
companies = self.search([])
companies.write({"today": fields.Date.today()})
today = fields.Date.today()
if companies and companies[0].today != today:
companies.write({"today": today})