diff --git a/.flake8 b/.flake8 index 486bc7ed..800fd9f4 100644 --- a/.flake8 +++ b/.flake8 @@ -11,3 +11,4 @@ select = C,E,F,W,B,B9 ignore = E203,E501,W503,B950,C901 per-file-ignores= __init__.py:F401 + **/__manifest__.py:B018 diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..d33e445d --- /dev/null +++ b/.gitignore @@ -0,0 +1,88 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +/.venv +/.pytest_cache +/.ruff_cache + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +bin/ +build/ +develop-eggs/ +dist/ +eggs/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg +*.eggs + +# Windows installers +*.msi + +# Debian packages +*.deb + +# Redhat packages +*.rpm + +# MacOS packages +*.dmg +*.pkg + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.cache +nosetests.xml +coverage.xml + +# Translations +*.mo + +# Pycharm +.idea + +# Eclipse +.settings + +# Visual Studio cache/options directory +.vs/ +.vscode + +# OSX Files +.DS_Store + +# Django stuff: +*.log + +# Mr Developer +.mr.developer.cfg +.project +.pydevproject + +# Rope +.ropeproject + +# Sphinx documentation +docs/_build/ + +# Backup files +*~ +*.swp + +# OCA rules +!static/lib/ \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4d27d4f7..432949e0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -62,7 +62,7 @@ repos: - id: mixed-line-ending args: ["--fix=lf"] - repo: https://github.com/OCA/pylint-odoo - rev: 7.0.2 + rev: v9.1.3 hooks: - id: pylint_odoo name: pylint with optional checks @@ -89,11 +89,11 @@ repos: # - --header # - "# generated from manifests external_dependencies" - repo: https://github.com/pycqa/flake8 - rev: 3.9.2 + rev: 7.0.0 hooks: - id: flake8 name: flake8 - additional_dependencies: ["flake8-bugbear==21.9.2"] + additional_dependencies: ["flake8-bugbear==24.2.6"] - repo: https://github.com/PyCQA/isort rev: 5.12.0 hooks: diff --git a/partner_telegram/__manifest__.py b/partner_telegram/__manifest__.py index bddcfacc..36c1ea99 100644 --- a/partner_telegram/__manifest__.py +++ b/partner_telegram/__manifest__.py @@ -1,11 +1,11 @@ -# Copyright 2024 Ivan Yelizariev +# Copyright 2026 Ivan Yelizariev # License MIT (https://opensource.org/licenses/MIT). { "name": "Telegram Contact Field", "summary": """Join the Amazing 😍 Community ⤵️""", "category": "VooDoo ✨ Magic", - "version": "17.0.1.0.0", + "version": "18.0.1.0.0", "author": "Ivan Kropotkin", "support": "info@odoomagic.com", "website": "https://sync_studio.t.me/", diff --git a/sync/__manifest__.py b/sync/__manifest__.py index 9d2a9410..e4fd2bae 100644 --- a/sync/__manifest__.py +++ b/sync/__manifest__.py @@ -1,4 +1,4 @@ -# Copyright 2020-2021,2024-2025 Ivan Yelizariev +# Copyright 2020-2021,2024-2026 Ivan Yelizariev # Copyright 2020-2021 Denis Mudarisov # Copyright 2021 Ilya Ilchenko # License MIT (https://opensource.org/licenses/MIT). @@ -7,7 +7,7 @@ "name": "Sync 🪬 Studio", "summary": """Join the Amazing 😍 Community ⤵️""", "category": "VooDoo ✨ Magic", - "version": "17.0.14.0.0", + "version": "18.0.1.0.0", "application": True, "author": "Ivan Yelizariev", "support": "info@odoomagic.com", diff --git a/sync/lib/tools/safe_eval.py b/sync/lib/tools/safe_eval.py index 28f2f21a..c6be53db 100644 --- a/sync/lib/tools/safe_eval.py +++ b/sync/lib/tools/safe_eval.py @@ -26,8 +26,6 @@ from psycopg2 import OperationalError import odoo -from odoo.tools.misc import ustr - unsafe_eval = eval __all__ = ["test_expr", "safe_eval", "const_eval"] @@ -71,7 +69,7 @@ def _import(name, globals=None, locals=None, fromlist=None, level=-1): # Generators "gi_code", "gi_frame", - "g_yieldfrom" + "gi_yieldfrom", # Coroutines "cr_await", "cr_code", @@ -134,6 +132,10 @@ def to_opcodes(opnames, _opmap=opmap): "SWAP", # Added in 3.11 https://docs.python.org/3/whatsnew/3.11.html#new-opcodes "RESUME", + # 3.12 https://docs.python.org/3/whatsnew/3.12.html#cpython-bytecode-changes + "RETURN_CONST", + # 3.13 + "TO_BOOL", ] ) ) @@ -182,6 +184,7 @@ def to_opcodes(opnames, _opmap=opmap): "GEN_START", # added in 3.10 but already removed from 3.11. # Added in 3.11, replacing all BINARY_* and INPLACE_* "BINARY_OP", + "BINARY_SLICE", ] ) ) @@ -266,6 +269,23 @@ def to_opcodes(opnames, _opmap=opmap): "NOP", "FORMAT_VALUE", "BUILD_STRING", + # 3.12 https://docs.python.org/3/whatsnew/3.12.html#cpython-bytecode-changes + "END_FOR", + "LOAD_FAST_AND_CLEAR", + "LOAD_FAST_CHECK", + "POP_JUMP_IF_NOT_NONE", + "POP_JUMP_IF_NONE", + "CALL_INTRINSIC_1", + "STORE_SLICE", + # 3.13 + "CALL_KW", + "LOAD_FAST_LOAD_FAST", + "STORE_FAST_STORE_FAST", + "STORE_FAST_LOAD_FAST", + "CONVERT_VALUE", + "FORMAT_SIMPLE", + "FORMAT_WITH_SPEC", + "SET_FUNCTION_ATTRIBUTE", ] ) ) @@ -522,7 +542,7 @@ def safe_eval__MAGIC( raise except Exception as e: raise ValueError( - '%s: "%s" while evaluating\n%r' % (ustr(type(e)), ustr(e), expr) + '%s: "%s" while evaluating\n%r' % (ustr(type(e))(e), expr) ) @@ -545,7 +565,7 @@ def test_python_expr__MAGIC(expr, mode="eval"): error["error_line"], ) else: - msg = ustr(err) + msg = err return msg return False diff --git a/sync/models/sync_project.py b/sync/models/sync_project.py index c7892371..13d51e45 100644 --- a/sync/models/sync_project.py +++ b/sync/models/sync_project.py @@ -672,7 +672,7 @@ def magic_upgrade(self): task_vals, task_technical_name, namespace=self.id ) - def create_trigger(model, data): + def create_trigger(model, data, task=task): vals = dict( {key: value for key, value in data.items() if value is not None}, sync_task_id=task.id, diff --git a/sync/models/sync_project_demo.py b/sync/models/sync_project_demo.py index 32c853ba..44a139d8 100644 --- a/sync/models/sync_project_demo.py +++ b/sync/models/sync_project_demo.py @@ -131,7 +131,7 @@ def _trello(secrets): if not getattr(secrets, key): raise Exception("{} is not set".format(key)) - # https://github.com/sarumont/py-trello/tree/master/trello + # https://github.com/sarumont/py-trello/list/master/trello from trello import TrelloClient from trello.exceptions import ResourceUnavailable diff --git a/sync/models/sync_trigger_automation.py b/sync/models/sync_trigger_automation.py index fe9ffe40..f4a1a0e8 100644 --- a/sync/models/sync_trigger_automation.py +++ b/sync/models/sync_trigger_automation.py @@ -8,6 +8,38 @@ _logger = logging.getLogger(__name__) +class BaseAutomationTriggerFix(models.Model): + """Override _compute_trigger to preserve existing values. + + Odoo 18's base.automation._compute_trigger depends on model_id and + unconditionally resets trigger to False. This breaks programmatic + creation/update where model_id and trigger are set together, because + the ORM recomputation overrides the explicit value at flush time. + + The ORM invalidates the field cache before calling compute, so reading + record.trigger inside compute returns the default (False) instead of + the stored DB value. We must read directly from the database. + """ + + _inherit = "base.automation" + + @api.depends("model_id") + def _compute_trigger(self): + # Read stored trigger values directly from DB — the ORM cache is + # invalidated before compute runs, so record.trigger would return + # False even when the DB holds a valid value. + stored = {} + existing = self.filtered("id") + if existing: + self.env.cr.execute( + "SELECT id, trigger FROM base_automation WHERE id IN %s", + [tuple(existing.ids)], + ) + stored = dict(self.env.cr.fetchall()) + for record in self: + record.trigger = stored.get(record.id) or False + + class SyncTriggerAutomation(models.Model): _name = "sync.trigger.automation" diff --git a/sync/models/sync_trigger_cron.py b/sync/models/sync_trigger_cron.py index 690a2933..1066f538 100644 --- a/sync/models/sync_trigger_cron.py +++ b/sync/models/sync_trigger_cron.py @@ -65,7 +65,5 @@ def name_get(self): r.interval_number, r.interval_type, ) - if r.numbercall > 0: - name += " (%s times)" % r.numbercall result.append((r.id, name)) return result diff --git a/sync/tools.py b/sync/tools.py index 7a713e17..36813052 100644 --- a/sync/tools.py +++ b/sync/tools.py @@ -252,7 +252,7 @@ def add_items(container, *args, **kwargs): else: raise Exception( f"The container received a non-callable positional argument of type " - f"'{type(item).__name__}', which lacks an explicit name. " + f"{type(item).__name__!r}, which lacks an explicit name. " f"Please pass a callable, a dictionary, or provide a key-value pair using keyword arguments." ) container.update(kwargs) diff --git a/sync/views/ir_logging_views.xml b/sync/views/ir_logging_views.xml index 182494a2..81419b6a 100644 --- a/sync/views/ir_logging_views.xml +++ b/sync/views/ir_logging_views.xml @@ -3,10 +3,10 @@ License MIT (https://opensource.org/licenses/MIT). --> - ir.logging.tree + ir.logging.list ir.logging - - + @@ -88,13 +88,13 @@ Logs ir.logging - tree,form + list,form [('sync_job_id', '!=', False)] @@ -108,37 +108,37 @@ Project Logs ir.logging - tree,form + list,form [('sync_project_id', '=', active_id)] Task Logs ir.logging - tree,form + list,form [('sync_task_id', '=', active_id)] Job Logs ir.logging - tree,form + list,form [('sync_job_id', '=', active_id)] diff --git a/sync/views/sync_job_views.xml b/sync/views/sync_job_views.xml index 53adddc5..1d451223 100644 --- a/sync/views/sync_job_views.xml +++ b/sync/views/sync_job_views.xml @@ -3,10 +3,10 @@ License MIT (https://opensource.org/licenses/MIT). --> - sync.job.tree + sync.job.list sync.job - - + @@ -97,7 +97,7 @@ readonly="1" editable="bottom" > - - +
@@ -116,7 +116,7 @@ - - + @@ -171,21 +171,21 @@ Project Jobs sync.job - tree,form + list,form [('project_id', '=', active_id)] Task Jobs sync.job - tree,form + list,form [('task_id', '=', active_id)] Jobs sync.job - tree,form + list,form - sync.link.tree + sync.link.list sync.link - + @@ -15,7 +15,7 @@ - + @@ -78,13 +78,13 @@ Links sync.link - tree,form + list,form Links sync.link - tree,form + list,form [('project_id', '=', active_id)] {'default_project_id': active_id, 'active_test': False} diff --git a/sync/views/sync_order_views.xml b/sync/views/sync_order_views.xml index 6f1eee22..973c7af2 100644 --- a/sync/views/sync_order_views.xml +++ b/sync/views/sync_order_views.xml @@ -3,14 +3,14 @@ License MIT (https://opensource.org/licenses/MIT). --> - sync.order.tree + sync.order.list sync.order - + - + @@ -65,12 +65,12 @@ - + - + @@ -88,18 +88,14 @@ -
- - - -
+
Sync Orders sync.order - tree,form + list,form [('sync_project_id', '=', active_id)]
diff --git a/sync/views/sync_project_views.xml b/sync/views/sync_project_views.xml index 9022ff71..7165d5ae 100644 --- a/sync/views/sync_project_views.xml +++ b/sync/views/sync_project_views.xml @@ -6,17 +6,17 @@ Sync Projects sync.project - tree,form + list,form {"active_test": False} - sync.project.tree + sync.project.list sync.project - + - + @@ -165,7 +165,7 @@ - +