Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
yelizariev committed May 7, 2024
1 parent eb0cb54 commit e06307d
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 20 deletions.
5 changes: 5 additions & 0 deletions sync/doc/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
`7.0.0`
-------

- **New:** Dramatic improvement on Sync Studio API

`6.2.0`
-------

Expand Down
12 changes: 11 additions & 1 deletion sync/models/sync_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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="""
Expand Down Expand Up @@ -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()

Expand Down
2 changes: 2 additions & 0 deletions sync/models/sync_project_demo.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# WARNING: This file is obsolete and will be deleted soon

# Copyright 2020 Ivan Yelizariev <https://twitter.com/yelizariev>
# Copyright 2020 Denis Mudarisov <https://github.com/trojikman>
# License MIT (https://opensource.org/licenses/MIT).
Expand Down
55 changes: 36 additions & 19 deletions sync/views/sync_project_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -147,27 +147,24 @@
<field name="description" nolabel="1" />
</div>
</page>
<page name="buttons" string="Manual Triggers">
<p class="oe_edit_only">
<br />
Hint: to add manual triggers navigate to corresponding
Task via "Available Tasks" tab
<page name="core" string="CORE.🪬">
<p>
<em>
For security reasons, the
<b>Core 🪬 Code</b>
can be updated via gist page only. For any custom
code use the
<b>Private ✨ Library</b>
tab instead.
</em>
</p>
<field name="trigger_button_ids">
<tree create="0">
<field name="sync_task_id" />
<field name="trigger_name" />
<button
name="start_button"
string="Run Now"
class="oe_highlight"
type="object"
/>
<field name="name" />
</tree>
</field>
<field
name="core_code"
widget="ace"
options="{'mode': 'python'}"
/>
</page>
<page name="code" string="Evaluation Context">
<page name="code" string="LIB.✨">
<group>
<field
name="eval_context_ids"
Expand All @@ -189,6 +186,26 @@
options="{'mode': 'python'}"
/>
</page>
<page name="buttons" string="Manual Triggers">
<p class="oe_edit_only">
<br />
Hint: to add manual triggers navigate to corresponding
Task via "Available Tasks" tab
</p>
<field name="trigger_button_ids">
<tree create="0">
<field name="sync_task_id" />
<field name="trigger_name" />
<button
name="start_button"
string="Run Now"
class="oe_highlight"
type="object"
/>
<field name="name" />
</tree>
</field>
</page>
<page name="tasks" string="Available Tasks">
<field name="task_ids" context="{'active_test': False}">
<tree decoration-muted="not active">
Expand Down

0 comments on commit e06307d

Please sign in to comment.