From e06307d5bd9d37dca46b65412af0b2c00ec23be6 Mon Sep 17 00:00:00 2001 From: Ivan Kropotkin Date: Tue, 7 May 2024 13:51:07 +0200 Subject: [PATCH] WIP --- sync/doc/changelog.rst | 5 +++ sync/models/sync_project.py | 12 ++++++- sync/models/sync_project_demo.py | 2 ++ sync/views/sync_project_views.xml | 55 ++++++++++++++++++++----------- 4 files changed, 54 insertions(+), 20 deletions(-) diff --git a/sync/doc/changelog.rst b/sync/doc/changelog.rst index df5ebd01..1515164c 100644 --- a/sync/doc/changelog.rst +++ b/sync/doc/changelog.rst @@ -1,3 +1,8 @@ +`7.0.0` +------- + +- **New:** Dramatic improvement on Sync Studio API + `6.2.0` ------- diff --git a/sync/models/sync_project.py b/sync/models/sync_project.py index 53259375..57e76104 100644 --- a/sync/models/sync_project.py +++ b/sync/models/sync_project.py @@ -10,7 +10,7 @@ from pytz import timezone from odoo import api, fields, models -from odoo.exceptions import UserError, ValidationError +from odoo.exceptions import AccessError, UserError, ValidationError from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT, frozendict, html2plaintext from odoo.tools.misc import get_lang from odoo.tools.safe_eval import ( @@ -64,6 +64,8 @@ class SyncProject(models.Model): ) eval_context_description = fields.Text(compute="_compute_eval_context_description") + core_code = fields.Text(string="Core Code", readonly=True) + common_code = fields.Text( "Common Code", help=""" @@ -152,6 +154,14 @@ def _check_python_code(self): if msg: raise ValidationError(msg) + def write(self, vals): + if "core_code" in vals and not self.env.user.has_group( + "sync.sync_group_manager" + ): + raise AccessError(_("Only Administrator can update the Core Code.")) + + return super().write(vals) + def _get_log_function(self, job, function): self.ensure_one() diff --git a/sync/models/sync_project_demo.py b/sync/models/sync_project_demo.py index 68104c5c..32c853ba 100644 --- a/sync/models/sync_project_demo.py +++ b/sync/models/sync_project_demo.py @@ -1,3 +1,5 @@ +# WARNING: This file is obsolete and will be deleted soon + # Copyright 2020 Ivan Yelizariev # Copyright 2020 Denis Mudarisov # License MIT (https://opensource.org/licenses/MIT). diff --git a/sync/views/sync_project_views.xml b/sync/views/sync_project_views.xml index 71803662..bd80ad38 100644 --- a/sync/views/sync_project_views.xml +++ b/sync/views/sync_project_views.xml @@ -147,27 +147,24 @@ - -

-
- Hint: to add manual triggers navigate to corresponding - Task via "Available Tasks" tab + +

+ + For security reasons, the + Core 🪬 Code + can be updated via gist page only. For any custom + code use the + Private ✨ Library + tab instead. +

- - - - -