From a1006a00df9b9a0b927cb897db465fd6f4bb6590 Mon Sep 17 00:00:00 2001 From: Carmen Bianca Bakker Date: Fri, 28 Oct 2022 13:39:00 +0200 Subject: [PATCH 1/2] [FIX] company_today: Execute every 15 min, remove doall Signed-off-by: Carmen Bianca Bakker --- company_today/data/ir_cron.xml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/company_today/data/ir_cron.xml b/company_today/data/ir_cron.xml index a5b0efe0f..2fc1c6f25 100644 --- a/company_today/data/ir_cron.xml +++ b/company_today/data/ir_cron.xml @@ -10,9 +10,19 @@ SPDX-License-Identifier: AGPL-3.0-or-later model.cron_update_today() - 1 + 15 minutes + + -1 - 1 + 0 From e61ecef0d766cd06f9d8cb10757c1164f92ba2f1 Mon Sep 17 00:00:00 2001 From: Carmen Bianca Bakker Date: Mon, 31 Oct 2022 08:25:33 +0100 Subject: [PATCH 2/2] [FIX] company_today: Check whether date has changed before writing it All fields are recomputed when the dependent field is written to, even if the value of the dependent field did not change. By reducing the amount of writes to the field, we reduce the amount of recomputation. Signed-off-by: Carmen Bianca Bakker --- company_today/models/res_company.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/company_today/models/res_company.py b/company_today/models/res_company.py index cf738c428..747f2c42c 100644 --- a/company_today/models/res_company.py +++ b/company_today/models/res_company.py @@ -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})