From cd03c24b34012f042b1e996babe904eacfb4d49e Mon Sep 17 00:00:00 2001 From: Ivan Kropotkin Date: Sat, 18 May 2024 17:44:41 +0200 Subject: [PATCH] :heart_eyes: sync: add PARAMS to core eval context --- sync/__manifest__.py | 2 +- sync/doc/changelog.rst | 6 ++++++ sync/models/sync_project.py | 12 ++++++++++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/sync/__manifest__.py b/sync/__manifest__.py index 9a093f7b..bf40e8c9 100644 --- a/sync/__manifest__.py +++ b/sync/__manifest__.py @@ -7,7 +7,7 @@ "name": "Sync 🪬 Studio", "summary": """Join the Amazing 😍 Community ⤵️""", "category": "VooDoo ✨ Magic", - "version": "16.0.11.0.0", + "version": "16.0.11.0.1", "application": True, "author": "Ivan Kropotkin", "support": "info@odoomagic.com", diff --git a/sync/doc/changelog.rst b/sync/doc/changelog.rst index ba973bcc..38053cc1 100644 --- a/sync/doc/changelog.rst +++ b/sync/doc/changelog.rst @@ -1,3 +1,9 @@ +`11.0.1` +------- + +- **Improvement:** add `PARAMS.*` to the core eval context +- **Improvement:** clarify error message when model is not found + `11.0.0` ------- diff --git a/sync/models/sync_project.py b/sync/models/sync_project.py index ae26066a..46b9e7e2 100644 --- a/sync/models/sync_project.py +++ b/sync/models/sync_project.py @@ -327,15 +327,16 @@ def record2image(record, fname="image_1920"): DATA[d.name] = d core_eval_context = { - "MAGIC": MAGIC, "SECRETS": SECRETS, + "MAGIC": MAGIC, + "PARAMS": PARAMS, } CORE = eval_export(safe_eval__MAGIC, self.core_code, core_eval_context) lib_eval_context = { "MAGIC": MAGIC, - "CORE": CORE, "PARAMS": PARAMS, + "CORE": CORE, "WEBHOOKS": WEBHOOKS, "DATA": DATA, } @@ -596,6 +597,13 @@ def create_trigger(model, data): for data in meta.get("DB_TRIGGERS", []): model_id = self.env["ir.model"]._get(data["model"]).id + if not model_id: + raise ValidationError( + _( + "Model %s is not available. Check if you need to install an extra module first." + ) + % data["model"] + ) create_trigger( "sync.trigger.automation", dict(data, model_id=model_id, model=None) )