From d8c2782d1fa0c5b6ebdd03875921928e5c4e11cf Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Tue, 18 Feb 2025 11:42:38 +0100 Subject: [PATCH] [IMP] runbot_merge: add cron trigger button "Run manually" is a bit meh, as it runs the cron synchronously (so you have to wait for it, and hope it doesn't run for longer than the request timeout which may be smaller than the cron timeout) and it can run in a subtly different environment than normal, which can lead to different behaviour. Instead add a button to enqueue a cron trigger, now that they exist that's much closer to what we actually want, and it does run the cron in a normal / expected environment. --- runbot_merge/__manifest__.py | 1 + runbot_merge/models/__init__.py | 4 +++- runbot_merge/models/ir_cron/__init__.py | 10 ++++++++++ runbot_merge/models/ir_cron/views.xml | 15 +++++++++++++++ 4 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 runbot_merge/models/ir_cron/__init__.py create mode 100644 runbot_merge/models/ir_cron/views.xml diff --git a/runbot_merge/__manifest__.py b/runbot_merge/__manifest__.py index 3688a1e7..7d37c0de 100644 --- a/runbot_merge/__manifest__.py +++ b/runbot_merge/__manifest__.py @@ -21,6 +21,7 @@ 'models/project_freeze/views.xml', 'models/staging_cancel/views.xml', 'models/backport/views.xml', + 'models/ir_cron/views.xml', ], 'assets': { 'web._assets_primary_variables': [ diff --git a/runbot_merge/models/__init__.py b/runbot_merge/models/__init__.py index 5c79a31a..0bd9ecd8 100644 --- a/runbot_merge/models/__init__.py +++ b/runbot_merge/models/__init__.py @@ -1,7 +1,9 @@ -from . import mail_thread from . import ir_actions +from . import ir_cron from . import ir_ui_view +from . import mail_thread from . import res_partner + from . import project from . import pull_requests from . import batch diff --git a/runbot_merge/models/ir_cron/__init__.py b/runbot_merge/models/ir_cron/__init__.py new file mode 100644 index 00000000..3404d0f9 --- /dev/null +++ b/runbot_merge/models/ir_cron/__init__.py @@ -0,0 +1,10 @@ +from odoo import models + + +class IrCron(models.Model): + _inherit = 'ir.cron' + + def trigger(self): + self.check_access_rights('write') + self._trigger() + return True diff --git a/runbot_merge/models/ir_cron/views.xml b/runbot_merge/models/ir_cron/views.xml new file mode 100644 index 00000000..ca8a86ab --- /dev/null +++ b/runbot_merge/models/ir_cron/views.xml @@ -0,0 +1,15 @@ + + + replace "run manually" by "trigger" + ir.cron + + + +