From 36abfc5b9e7cbe37bbe5815a2adbe6f4ed3f87df Mon Sep 17 00:00:00 2001 From: Ivan Yelizariev Date: Mon, 3 Mar 2025 16:49:38 +0100 Subject: [PATCH 1/2] :zap: sync: add SECRETS._update_secret --- sync/doc/changelog.rst | 3 ++- sync/models/sync_project.py | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/sync/doc/changelog.rst b/sync/doc/changelog.rst index 624e2890..5ca32cbc 100644 --- a/sync/doc/changelog.rst +++ b/sync/doc/changelog.rst @@ -1,8 +1,9 @@ -`13.0.1` +`14.0.0` ------- - **New:** sync.order: attaching multiple records via new line_ids field; automatic link to sync.job record. - **New:** sync.task: save technical_name of the task for a better integration with Odoo UI (e.g. to call task via custom action) +- **New:** Add dynamic Secret update via `SECRETS._update_secret`. `13.0.1` ------- diff --git a/sync/models/sync_project.py b/sync/models/sync_project.py index c7892371..a19cafaf 100644 --- a/sync/models/sync_project.py +++ b/sync/models/sync_project.py @@ -357,7 +357,22 @@ def gen2csv(generator): "AttrDict": AttrDict, }, ) - SECRETS = AttrDict() + + def _update_secret(key, value): + SECRETS[key] = value + for p in self.secret_ids: + if p.key == key: + p.value = value + return + self.env["sync.project.secret"].create( + { + "project_id": self.id, + "key": key, + "value": value, + } + ) + + SECRETS = AttrDict(_update_secret) for p in self.secret_ids: SECRETS[p.key] = p.value From c6d47b464a87a34e3d35fb05cd5d841c42ed3cdc Mon Sep 17 00:00:00 2001 From: Ivan Yelizariev Date: Tue, 4 Mar 2025 14:35:22 +0100 Subject: [PATCH 2/2] :heart_eyes: sync: provide API for magic button customization --- sync/models/sync_task.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sync/models/sync_task.py b/sync/models/sync_task.py index 6c2c0619..b6a85268 100644 --- a/sync/models/sync_task.py +++ b/sync/models/sync_task.py @@ -103,7 +103,7 @@ def _compute_active_triggers(self): r.active_automation_ids = r.with_context(active_test=True).automation_ids r.active_webhook_ids = r.with_context(active_test=True).webhook_ids - def action_magic_button(self): + def _magic_button(self): # TODO: This should be refactored, because we use single button per task if not self.button_ids: self.button_ids.create( @@ -113,7 +113,11 @@ def action_magic_button(self): "sync_task_id": self.id, } ) - return self.button_ids.start_button() + + return self.button_ids + + def action_magic_button(self): + return self._magic_button().start_button() def _get_current_date_formatted(self): user_lang = self.env.user.lang or "en_US"