[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.
This commit is contained in:
Xavier Morel 2025-02-18 11:42:38 +01:00
parent e19a9fad8f
commit d8c2782d1f
4 changed files with 29 additions and 1 deletions

View File

@ -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': [

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,15 @@
<odoo>
<record id="ir_cron_view_form" model="ir.ui.view">
<field name="name">replace "run manually" by "trigger"</field>
<field name="model">ir.cron</field>
<field name="inherit_id" ref="base.ir_cron_view_form"/>
<field name="arch" type="xml">
<xpath expr="//button[@name='method_direct_trigger']" position="after">
<button name="trigger" type="object" string="Trigger" class="oe_highlight" invisible="state != 'code'"/>
</xpath>
<xpath expr="//button[@name='method_direct_trigger']" position="attributes">
<attribute name="class"/>
</xpath>
</field>
</record>
</odoo>