mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
[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.
This commit is contained in:
committed by
Pedro M. Baeza
parent
be5e2ec6f8
commit
44ca0f6a62
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user