Skip to content

Commit 4ca1edc

Browse files
committed
[IMP] runbot: add a button to disable regular triggers
It's sometimes useful to disable regular triggers on a bundle to only starts manual or custom triggers. With this commit, a button is added on the bundle page to disable regular triggers by creating disabled custom triggers.
1 parent 027f17e commit 4ca1edc

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

runbot/models/bundle.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,28 @@ def action_generate_custom_trigger_restore_action(self):
329329
}
330330
return self._generate_custom_trigger_action(context)
331331

332+
def action_disable_all_triggers(self):
333+
triggers_to_disable = (
334+
self.env["runbot.trigger"]
335+
.search([
336+
("id", "not in", self.trigger_custom_ids.trigger_id.ids),
337+
("project_id", "=", self.project_id.id),
338+
("manual", "=", False),
339+
("category_id", "=", 1),
340+
])
341+
.filtered(
342+
lambda rec: not rec.version_domain or self.version_id.filtered_domain(rec._get_version_domain()),
343+
)
344+
)
345+
vals = []
346+
for trigger in triggers_to_disable:
347+
vals.append({
348+
'bundle_id': self.id,
349+
'trigger_id': trigger.id,
350+
'start_mode': 'disabled',
351+
})
352+
self.env['runbot.bundle.trigger.custom'].create(vals)
353+
332354

333355
class BundleTag(models.Model):
334356

runbot/views/bundle_views.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
<header>
4444
<button name="action_generate_custom_trigger_multi_action" string="New custom multi" type="object" class="oe_highlight"/>
4545
<button name="action_generate_custom_trigger_restore_action" string="New custom restore" type="object" class="oe_highlight"/>
46+
<button name="action_disable_all_triggers" string="Disable regular triggers" type="object" class="oe_highlight"/>
4647
</header>
4748
<sheet>
4849
<group>

0 commit comments

Comments
 (0)