Skip to content

Commit a1c8b6f

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 a1c8b6f

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

runbot/models/bundle.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,20 @@ 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 = self.env['runbot.trigger'].search([
334+
('project_id', '=', self.project_id), ('manual', '=', False),
335+
('category_id', '=', 1),
336+
]).filtered(lambda rec: not rec.version_domain or self.version_id.filtered_domain(rec._get_version_domain()))
337+
vals = []
338+
for trigger in triggers_to_disable:
339+
vals.append({
340+
'bundle_id': self.id,
341+
'trigger_id': trigger.id,
342+
'start_mode': 'disabled',
343+
})
344+
self.env['runbot.bundle.trigger.custom'].create(vals)
345+
332346

333347
class BundleTag(models.Model):
334348

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)