Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
yelizariev committed May 8, 2024
1 parent 1f5d2af commit b6a0bd1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
15 changes: 13 additions & 2 deletions sync/models/sync_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ class SyncTask(models.Model):
code_check = fields.Text("Syntax check", store=False, readonly=True)
active = fields.Boolean(default=True)
magic_button = fields.Char()
button_ids = fields.One2many(
"sync.trigger.button", "sync_task_id", string="Manual Triggers", copy=True
)
cron_ids = fields.One2many("sync.trigger.cron", "sync_task_id", copy=True)
automation_ids = fields.One2many(
"sync.trigger.automation", "sync_task_id", copy=True
Expand Down Expand Up @@ -92,8 +95,16 @@ def _compute_active_triggers(self):
r.active_webhook_ids = r.with_context(active_test=True).webhook_ids

def action_magic_button(self):
# TODO
pass
# TODO: This should be refactored to delete button_ids
if not self.button_ids:
self.button_ids.create(
{
"name": self.magic_button,
"trigger_name": self.magic_button,
"sync_task_id": self.id,
}
)
return self.button_ids.start_button()

def start(
self, trigger, args=None, with_delay=False, force=False, raise_on_error=True
Expand Down
5 changes: 3 additions & 2 deletions sync/views/sync_project_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,16 @@
<tree decoration-muted="not active">
<field name="name" />
<field name="active" />
<field name="magic_button" invisible="1" />
<!-- TODO: make title name equal to magic_button -->
<button
name="action_magic_button"
title="Magic ✨ Button"
string="Magic ✨"
help="All you need to do is click the **Magic 🪬 Button**"
type="object"
class="oe_highlight"
attrs="{'invisible': ['|', ('magic_button', '=', False), ('magic_button', '=', '')]}"
/>
<field name="magic_button" invisible="1" />
<field
name="active_cron_ids"
widget="many2many_tags"
Expand Down

0 comments on commit b6a0bd1

Please sign in to comment.