[FIX] base: log cron start/done also when running manually

The INFO "Starting job x" and "Job x done" logs are only logged for the
automatic executing of the cron by the cron worker. When running the
cron manually via its form view, no INFO was logged.

The technical support is reporting problems where a cron server action
is running twice at a same moment leading to problems such as
mass-mailing sending emails twice. There is a mutual exclusion mechanism
for cron workers but no exclusion mechanism seems in place for http
worker vs cron worker. Logging the "run manually" actions will help us
figuring out the problems.

X-original-commit: fcc2eabc671557e610688eac93bae333b0a2c119
Part-of: odoo/odoo#157203
This commit is contained in:
Julien Castiaux
2024-03-11 15:03:06 +00:00
parent 3ab2d52b1f
commit ca197d2a71
+2
View File
@@ -93,7 +93,9 @@ class ir_cron(models.Model):
def method_direct_trigger(self):
self.check_access_rights('write')
for cron in self:
_logger.info('Manually starting job `%s`.', cron.name)
cron.with_user(cron.user_id).with_context({'lastcall': cron.lastcall}).ir_actions_server_id.run()
_logger.info('Job `%s` done.', cron.name)
cron.lastcall = fields.Datetime.now()
return True