From 44ca0f6a629eeb7e065f38b241f1b097d861706e Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Fri, 9 Nov 2018 18:52:13 +0100 Subject: [PATCH] [10.0] currency_rate_update: more robust cron execution (#724) With the current implementation, when there is a single failure in the download of currencies via cron, the field next_run is not updated, and then it the download stops forever... until someone updates next_run manually. This commit fixes that. --- currency_rate_update/models/currency_rate_update.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/currency_rate_update/models/currency_rate_update.py b/currency_rate_update/models/currency_rate_update.py index d50533e3a..f4e32f79f 100644 --- a/currency_rate_update/models/currency_rate_update.py +++ b/currency_rate_update/models/currency_rate_update.py @@ -200,7 +200,7 @@ class CurrencyRateUpdateService(models.Model): if self._context.get('cron'): midnight = time(0, 0) next_run = (datetime.combine( - fields.Date.from_string(srv.next_run), + datetime.today(), midnight) + _intervalTypes[str(srv.interval_type)] (srv.interval_number)).date() @@ -210,7 +210,7 @@ class CurrencyRateUpdateService(models.Model): @api.multi def run_currency_update(self): # Update currency at the given frequence - services = self.search([('next_run', '=', fields.Date.today())]) + services = self.search([('next_run', '<=', fields.Date.today())]) services.with_context(cron=True).refresh_currency() @api.model