diff --git a/addons/rpc_helper/README.rst b/addons/rpc_helper/README.rst deleted file mode 100644 index dcd8d23..0000000 --- a/addons/rpc_helper/README.rst +++ /dev/null @@ -1,139 +0,0 @@ -=========== -Disable RPC -=========== - -.. - !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! This file is generated by oca-gen-addon-readme !! - !! changes will be overwritten. !! - !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:3e95cc80fbae1cb569a46d799e19ecc6edf4f605f8d131a25bed6daf5057b512 - !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png - :target: https://odoo-community.org/page/development-status - :alt: Beta -.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png - :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html - :alt: License: LGPL-3 -.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github - :target: https://github.com/OCA/server-tools/tree/16.0/rpc_helper - :alt: OCA/server-tools -.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/server-tools-16-0/server-tools-16-0-rpc_helper - :alt: Translate me on Weblate -.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png - :target: https://runboat.odoo-community.org/builds?repo=OCA/server-tools&target_branch=16.0 - :alt: Try me on Runboat - -|badge1| |badge2| |badge3| |badge4| |badge5| - -Provide helpers to authorize RPC calls. - -**Table of contents** - -.. contents:: - :local: - -Configuration -============= - -Enable debug mode and go to "Technical -> Database Structure -> Models". - -Open the model that you like to configure and go to the tab "RPC config". - -There you see a text field which supports JSON configuration. - -The configuration is the same you can pass via decorator. -The only difference is that you have to wrap values in a dictionary -like `{"disable": [...values...]}`. - -To disable all calls:: - - { - "disable": ["all"], - } - -To disable only some methods:: - - { - "disable": ["create", "write", "another_method"], - } - -NOTE: on the resulting JSON will be automatically formatted on save for better readability. - -Usage -===== - -Via code -~~~~~~~~ - -Decorate an Odoo model class like this:: - - from odoo.addons.rpc_helper.decorator import disable_rpc - - @disable_rpc() - class AverageModel(models.Model): - _inherit = "avg.model" - -This will disable ALL calls. - -To selectively disable only some methods:: - - @disable_rpc("create", "write", "any_method") - class AverageModel(models.Model): - _inherit = "avg.model" - - -Via `ir.model` configuration -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -See "Configuration" section. - -Bug Tracker -=========== - -Bugs are tracked on `GitHub Issues `_. -In case of trouble, please check there if your issue has already been reported. -If you spotted it first, help us to smash it by providing a detailed and welcomed -`feedback `_. - -Do not contact contributors directly about support or help with technical issues. - -Credits -======= - -Authors -~~~~~~~ - -* Camptocamp - -Contributors -~~~~~~~~~~~~ - -* Simone Orsi - -Maintainers -~~~~~~~~~~~ - -This module is maintained by the OCA. - -.. image:: https://odoo-community.org/logo.png - :alt: Odoo Community Association - :target: https://odoo-community.org - -OCA, or the Odoo Community Association, is a nonprofit organization whose -mission is to support the collaborative development of Odoo features and -promote its widespread use. - -.. |maintainer-simahawk| image:: https://github.com/simahawk.png?size=40px - :target: https://github.com/simahawk - :alt: simahawk - -Current `maintainer `__: - -|maintainer-simahawk| - -This module is part of the `OCA/server-tools `_ project on GitHub. - -You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/addons/rpc_helper/__init__.py b/addons/rpc_helper/__init__.py deleted file mode 100644 index 5bf6749..0000000 --- a/addons/rpc_helper/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -from . import models -from .hooks import post_load_hook diff --git a/addons/rpc_helper/__manifest__.py b/addons/rpc_helper/__manifest__.py deleted file mode 100644 index b20a920..0000000 --- a/addons/rpc_helper/__manifest__.py +++ /dev/null @@ -1,17 +0,0 @@ -# Copyright 2022 Camptocamp SA -# @author: Simone Orsi -# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). - -{ - "name": "Disable RPC", - "summary": """Helpers for disabling RPC calls""", - "version": "16.0.1.0.0", - "development_status": "Beta", - "license": "LGPL-3", - "website": "https://github.com/OCA/server-tools", - "author": "Camptocamp, Odoo Community Association (OCA)", - "maintainers": ["simahawk"], - "depends": ["base_sparse_field"], - "data": ["views/ir_model_views.xml"], - "post_load": "post_load_hook", -} diff --git a/addons/rpc_helper/decorator.py b/addons/rpc_helper/decorator.py deleted file mode 100644 index 99c875c..0000000 --- a/addons/rpc_helper/decorator.py +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright 2022 Camptocamp SA -# @author: Simone Orsi -# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). - - -def disable_rpc(*config): - """Decorate classes to disable RPC calls. - - Possible values: - - * none, block all methods - * *("$method_name1", "$method_name2"), blocks calls to specific methods - """ - - def _decorator(target): - target._disable_rpc = ("all",) if len(config) == 0 else config - return target - - return _decorator diff --git a/addons/rpc_helper/hooks.py b/addons/rpc_helper/hooks.py deleted file mode 100644 index e6dbad6..0000000 --- a/addons/rpc_helper/hooks.py +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright 2022 Camptocamp SA -# @author: Simone Orsi -# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). - -import logging - -from odoo.service import model - -from .patch import protected__execute_cr - -_logger = logging.getLogger(__name__) - - -def patch__model_execute_cr(): - """Patch rpc model handler.""" - protected__execute_cr._orig__execute_cr = model.execute_cr - model.execute_cr = protected__execute_cr - _logger.info("PATCHED odoo.service.model.execute") - - -def post_load_hook(): - patch__model_execute_cr() diff --git a/addons/rpc_helper/i18n/es.po b/addons/rpc_helper/i18n/es.po deleted file mode 100644 index e3fba18..0000000 --- a/addons/rpc_helper/i18n/es.po +++ /dev/null @@ -1,113 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * rpc_helper -# -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 16.0\n" -"Report-Msgid-Bugs-To: \n" -"PO-Revision-Date: 2023-09-03 00:15+0000\n" -"Last-Translator: Ivorra78 \n" -"Language-Team: none\n" -"Language: es\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" -"Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 4.17\n" - -#. module: rpc_helper -#: model:ir.model.fields,field_description:rpc_helper.field_ir_model__changeset_change_ids -msgid "Changeset Changes" -msgstr "" - -#. module: rpc_helper -#: model:ir.model.fields,field_description:rpc_helper.field_ir_model__changeset_ids -msgid "Changesets" -msgstr "" - -#. module: rpc_helper -#: model:ir.model.fields,help:rpc_helper.field_ir_model__rpc_config_edit -msgid "" -"Configure RPC config via JSON. Value must be a list of methods to disable " -"wrapped by a dict with key `disable`. Eg: {'disable': ['search', 'do_this']}" -"To disable all methods, use `{'disable: ['all']}`" -msgstr "" -"Configurar RPC vía JSON. El valor debe ser una lista de métodos a " -"deshabilitar envueltos por un dict con la clave `disable`. Ej: {'disable': " -"['search', 'do_this']}Para deshabilitar todos los métodos, usa `{'disable: " -"['all']}`" - -#. module: rpc_helper -#: model:ir.model.fields,field_description:rpc_helper.field_ir_model__count_changesets -msgid "Count Changesets" -msgstr "" - -#. module: rpc_helper -#: model:ir.model.fields,field_description:rpc_helper.field_ir_model__count_pending_changeset_changes -msgid "Count Pending Changeset Changes" -msgstr "" - -#. module: rpc_helper -#: model:ir.model.fields,field_description:rpc_helper.field_ir_model__count_pending_changesets -msgid "Count Pending Changesets" -msgstr "" - -#. module: rpc_helper -#: model:ir.model,name:rpc_helper.model_ir_model -msgid "Models" -msgstr "Modelos" - -#. module: rpc_helper -#. odoo-python -#: code:addons/rpc_helper/patch.py:0 -#, python-format -msgid "Object %s doesn't exist" -msgstr "El objeto %s no existe" - -#. module: rpc_helper -#. odoo-python -#: code:addons/rpc_helper/patch.py:0 -#, python-format -msgid "RPC call on %s is not allowed" -msgstr "La llamada RPC en %s no está permitida" - -#. module: rpc_helper -#: model_terms:ir.ui.view,arch_db:rpc_helper.view_model_form -msgid "RPC config" -msgstr "Configuración RPC" - -#. module: rpc_helper -#: model:ir.model.fields,field_description:rpc_helper.field_ir_model__rpc_config -msgid "Rpc Config" -msgstr "Configuración Rpc" - -#. module: rpc_helper -#: model:ir.model.fields,field_description:rpc_helper.field_ir_model__rpc_config_edit -msgid "Rpc Config Edit" -msgstr "Editar configuración Rpc" - -#. module: rpc_helper -#: model:ir.model.fields,field_description:rpc_helper.field_ir_model__smart_search -msgid "Smart Search" -msgstr "Búsqueda inteligente" - -#. module: rpc_helper -#: model:ir.model.fields,help:rpc_helper.field_ir_model__count_pending_changeset_changes -msgid "The number of pending changes of this record" -msgstr "" - -#. module: rpc_helper -#: model:ir.model.fields,help:rpc_helper.field_ir_model__count_pending_changesets -msgid "The number of pending changesets of this record" -msgstr "" - -#. module: rpc_helper -#: model:ir.model.fields,help:rpc_helper.field_ir_model__count_changesets -msgid "The overall number of changesets of this record" -msgstr "" - -#. module: rpc_helper -#: model:ir.model.fields,field_description:rpc_helper.field_ir_model__user_can_see_changeset -msgid "User Can See Changeset" -msgstr "" diff --git a/addons/rpc_helper/i18n/es_AR.po b/addons/rpc_helper/i18n/es_AR.po deleted file mode 100644 index aa2b409..0000000 --- a/addons/rpc_helper/i18n/es_AR.po +++ /dev/null @@ -1,122 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * rpc_helper -# -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 14.0\n" -"Report-Msgid-Bugs-To: \n" -"PO-Revision-Date: 2024-08-13 04:58+0000\n" -"Last-Translator: Ignacio Buioli \n" -"Language-Team: none\n" -"Language: es_AR\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" -"Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 5.6.2\n" - -#. module: rpc_helper -#: model:ir.model.fields,field_description:rpc_helper.field_ir_model__changeset_change_ids -msgid "Changeset Changes" -msgstr "Cambios del Conjunto de Cambios" - -#. module: rpc_helper -#: model:ir.model.fields,field_description:rpc_helper.field_ir_model__changeset_ids -msgid "Changesets" -msgstr "Conjunto de Cambios" - -#. module: rpc_helper -#: model:ir.model.fields,help:rpc_helper.field_ir_model__rpc_config_edit -msgid "" -"Configure RPC config via JSON. Value must be a list of methods to disable " -"wrapped by a dict with key `disable`. Eg: {'disable': ['search', 'do_this']}" -"To disable all methods, use `{'disable: ['all']}`" -msgstr "" -"Configure los ajustes de RPC a través de JSON. El valor debe ser una lista " -"de métodos para deshabilitar envueltos por un dict con la clave " -"`deshabilitar`. Por ejemplo: {'disable': ['search', 'do_this']} Para " -"deshabilitar todos los métodos, use `{'disable: ['all']}`" - -#. module: rpc_helper -#: model:ir.model.fields,field_description:rpc_helper.field_ir_model__count_changesets -msgid "Count Changesets" -msgstr "Cuenta de Configuración de Cambios" - -#. module: rpc_helper -#: model:ir.model.fields,field_description:rpc_helper.field_ir_model__count_pending_changeset_changes -msgid "Count Pending Changeset Changes" -msgstr "Cuenta de los Cambios Pendientes de los Conjuntos de Cambios" - -#. module: rpc_helper -#: model:ir.model.fields,field_description:rpc_helper.field_ir_model__count_pending_changesets -msgid "Count Pending Changesets" -msgstr "Cuenta de los Conjuntos de Cambios Pendientes" - -#. module: rpc_helper -#: model:ir.model,name:rpc_helper.model_ir_model -msgid "Models" -msgstr "Modelos" - -#. module: rpc_helper -#. odoo-python -#: code:addons/rpc_helper/patch.py:0 -#, python-format -msgid "Object %s doesn't exist" -msgstr "El Objeto %s no existe" - -#. module: rpc_helper -#. odoo-python -#: code:addons/rpc_helper/patch.py:0 -#, python-format -msgid "RPC call on %s is not allowed" -msgstr "Las llamadas RPC en %s no están permitidas" - -#. module: rpc_helper -#: model_terms:ir.ui.view,arch_db:rpc_helper.view_model_form -msgid "RPC config" -msgstr "Configuración RPC" - -#. module: rpc_helper -#: model:ir.model.fields,field_description:rpc_helper.field_ir_model__rpc_config -msgid "Rpc Config" -msgstr "Configuración Rpc" - -#. module: rpc_helper -#: model:ir.model.fields,field_description:rpc_helper.field_ir_model__rpc_config_edit -msgid "Rpc Config Edit" -msgstr "Editar la Configuración Rpc" - -#. module: rpc_helper -#: model:ir.model.fields,field_description:rpc_helper.field_ir_model__smart_search -msgid "Smart Search" -msgstr "Búsqueda Inteligente" - -#. module: rpc_helper -#: model:ir.model.fields,help:rpc_helper.field_ir_model__count_pending_changeset_changes -msgid "The number of pending changes of this record" -msgstr "El número de los cambios pendientes de este registro" - -#. module: rpc_helper -#: model:ir.model.fields,help:rpc_helper.field_ir_model__count_pending_changesets -msgid "The number of pending changesets of this record" -msgstr "El número de las configuraciones de cambios pendientes de este registro" - -#. module: rpc_helper -#: model:ir.model.fields,help:rpc_helper.field_ir_model__count_changesets -msgid "The overall number of changesets of this record" -msgstr "El número total de conjuntos de cambios de este registro" - -#. module: rpc_helper -#: model:ir.model.fields,field_description:rpc_helper.field_ir_model__user_can_see_changeset -msgid "User Can See Changeset" -msgstr "El Usuario Puede ver Conjuntos de Cambios" - -#~ msgid "Display Name" -#~ msgstr "Mostrar Nombre" - -#~ msgid "ID" -#~ msgstr "ID" - -#~ msgid "Last Modified on" -#~ msgstr "Última modificación en" diff --git a/addons/rpc_helper/i18n/it.po b/addons/rpc_helper/i18n/it.po deleted file mode 100644 index 722bd00..0000000 --- a/addons/rpc_helper/i18n/it.po +++ /dev/null @@ -1,113 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * rpc_helper -# -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 16.0\n" -"Report-Msgid-Bugs-To: \n" -"PO-Revision-Date: 2025-01-16 16:06+0000\n" -"Last-Translator: mymage \n" -"Language-Team: none\n" -"Language: it\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" -"Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 5.6.2\n" - -#. module: rpc_helper -#: model:ir.model.fields,field_description:rpc_helper.field_ir_model__changeset_change_ids -msgid "Changeset Changes" -msgstr "Modifiche dell'insieme di modifiche" - -#. module: rpc_helper -#: model:ir.model.fields,field_description:rpc_helper.field_ir_model__changeset_ids -msgid "Changesets" -msgstr "Insiemi di modifiche" - -#. module: rpc_helper -#: model:ir.model.fields,help:rpc_helper.field_ir_model__rpc_config_edit -msgid "" -"Configure RPC config via JSON. Value must be a list of methods to disable " -"wrapped by a dict with key `disable`. Eg: {'disable': ['search', 'do_this']}" -"To disable all methods, use `{'disable: ['all']}`" -msgstr "" -"Impostare configurazione RPC con JSON. Il valore deve essere un elenco di " -"metodi da disabilitare inseriti in un dizionario con chiave `disable`. Es. " -"{'disable': ['search', 'do_this']} Pr disabilitare tutti i metodi usare " -"`{'disable: ['all']}`" - -#. module: rpc_helper -#: model:ir.model.fields,field_description:rpc_helper.field_ir_model__count_changesets -msgid "Count Changesets" -msgstr "Conta insiemi di modifiche" - -#. module: rpc_helper -#: model:ir.model.fields,field_description:rpc_helper.field_ir_model__count_pending_changeset_changes -msgid "Count Pending Changeset Changes" -msgstr "Conteggio modifiche dell'insieme di modifiche in attesa" - -#. module: rpc_helper -#: model:ir.model.fields,field_description:rpc_helper.field_ir_model__count_pending_changesets -msgid "Count Pending Changesets" -msgstr "Conteggio insieme di modifiche in attesa" - -#. module: rpc_helper -#: model:ir.model,name:rpc_helper.model_ir_model -msgid "Models" -msgstr "Modelli" - -#. module: rpc_helper -#. odoo-python -#: code:addons/rpc_helper/patch.py:0 -#, python-format -msgid "Object %s doesn't exist" -msgstr "L'oggetto %s non esiste" - -#. module: rpc_helper -#. odoo-python -#: code:addons/rpc_helper/patch.py:0 -#, python-format -msgid "RPC call on %s is not allowed" -msgstr "La chiamata RPC su %s non è consentita" - -#. module: rpc_helper -#: model_terms:ir.ui.view,arch_db:rpc_helper.view_model_form -msgid "RPC config" -msgstr "Configurazione RPC" - -#. module: rpc_helper -#: model:ir.model.fields,field_description:rpc_helper.field_ir_model__rpc_config -msgid "Rpc Config" -msgstr "Configurazione RPC" - -#. module: rpc_helper -#: model:ir.model.fields,field_description:rpc_helper.field_ir_model__rpc_config_edit -msgid "Rpc Config Edit" -msgstr "Mdifica configurazione RPC" - -#. module: rpc_helper -#: model:ir.model.fields,field_description:rpc_helper.field_ir_model__smart_search -msgid "Smart Search" -msgstr "Ricerca intelligente" - -#. module: rpc_helper -#: model:ir.model.fields,help:rpc_helper.field_ir_model__count_pending_changeset_changes -msgid "The number of pending changes of this record" -msgstr "Numero di modifiche di questo record in attesa" - -#. module: rpc_helper -#: model:ir.model.fields,help:rpc_helper.field_ir_model__count_pending_changesets -msgid "The number of pending changesets of this record" -msgstr "Numero di insiemi di modifiche in attesa di questo record" - -#. module: rpc_helper -#: model:ir.model.fields,help:rpc_helper.field_ir_model__count_changesets -msgid "The overall number of changesets of this record" -msgstr "Numero totale di insiemi di modifiche di questo record" - -#. module: rpc_helper -#: model:ir.model.fields,field_description:rpc_helper.field_ir_model__user_can_see_changeset -msgid "User Can See Changeset" -msgstr "L'utente può vedere l'insieme delle modifiche" diff --git a/addons/rpc_helper/i18n/rpc_helper.pot b/addons/rpc_helper/i18n/rpc_helper.pot deleted file mode 100644 index 2d6b7e2..0000000 --- a/addons/rpc_helper/i18n/rpc_helper.pot +++ /dev/null @@ -1,106 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * rpc_helper -# -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 16.0\n" -"Report-Msgid-Bugs-To: \n" -"Last-Translator: \n" -"Language-Team: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" -"Plural-Forms: \n" - -#. module: rpc_helper -#: model:ir.model.fields,field_description:rpc_helper.field_ir_model__changeset_change_ids -msgid "Changeset Changes" -msgstr "" - -#. module: rpc_helper -#: model:ir.model.fields,field_description:rpc_helper.field_ir_model__changeset_ids -msgid "Changesets" -msgstr "" - -#. module: rpc_helper -#: model:ir.model.fields,help:rpc_helper.field_ir_model__rpc_config_edit -msgid "" -"Configure RPC config via JSON. Value must be a list of methods to disable " -"wrapped by a dict with key `disable`. Eg: {'disable': ['search', " -"'do_this']}To disable all methods, use `{'disable: ['all']}`" -msgstr "" - -#. module: rpc_helper -#: model:ir.model.fields,field_description:rpc_helper.field_ir_model__count_changesets -msgid "Count Changesets" -msgstr "" - -#. module: rpc_helper -#: model:ir.model.fields,field_description:rpc_helper.field_ir_model__count_pending_changeset_changes -msgid "Count Pending Changeset Changes" -msgstr "" - -#. module: rpc_helper -#: model:ir.model.fields,field_description:rpc_helper.field_ir_model__count_pending_changesets -msgid "Count Pending Changesets" -msgstr "" - -#. module: rpc_helper -#: model:ir.model,name:rpc_helper.model_ir_model -msgid "Models" -msgstr "" - -#. module: rpc_helper -#. odoo-python -#: code:addons/rpc_helper/patch.py:0 -#, python-format -msgid "Object %s doesn't exist" -msgstr "" - -#. module: rpc_helper -#. odoo-python -#: code:addons/rpc_helper/patch.py:0 -#, python-format -msgid "RPC call on %s is not allowed" -msgstr "" - -#. module: rpc_helper -#: model_terms:ir.ui.view,arch_db:rpc_helper.view_model_form -msgid "RPC config" -msgstr "" - -#. module: rpc_helper -#: model:ir.model.fields,field_description:rpc_helper.field_ir_model__rpc_config -msgid "Rpc Config" -msgstr "" - -#. module: rpc_helper -#: model:ir.model.fields,field_description:rpc_helper.field_ir_model__rpc_config_edit -msgid "Rpc Config Edit" -msgstr "" - -#. module: rpc_helper -#: model:ir.model.fields,field_description:rpc_helper.field_ir_model__smart_search -msgid "Smart Search" -msgstr "" - -#. module: rpc_helper -#: model:ir.model.fields,help:rpc_helper.field_ir_model__count_pending_changeset_changes -msgid "The number of pending changes of this record" -msgstr "" - -#. module: rpc_helper -#: model:ir.model.fields,help:rpc_helper.field_ir_model__count_pending_changesets -msgid "The number of pending changesets of this record" -msgstr "" - -#. module: rpc_helper -#: model:ir.model.fields,help:rpc_helper.field_ir_model__count_changesets -msgid "The overall number of changesets of this record" -msgstr "" - -#. module: rpc_helper -#: model:ir.model.fields,field_description:rpc_helper.field_ir_model__user_can_see_changeset -msgid "User Can See Changeset" -msgstr "" diff --git a/addons/rpc_helper/models/__init__.py b/addons/rpc_helper/models/__init__.py deleted file mode 100644 index 413bb23..0000000 --- a/addons/rpc_helper/models/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from . import ir_model diff --git a/addons/rpc_helper/models/ir_model.py b/addons/rpc_helper/models/ir_model.py deleted file mode 100644 index 6913b33..0000000 --- a/addons/rpc_helper/models/ir_model.py +++ /dev/null @@ -1,44 +0,0 @@ -# Copyright 2022 Camptocamp SA -# @author: Simone Orsi -# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). - -import json - -from odoo import api, fields, models, tools - -from odoo.addons.base_sparse_field.models.fields import Serialized - - -class IrModel(models.Model): - _inherit = "ir.model" - - rpc_config = Serialized(compute="_compute_rpc_config", default={}) - # Allow editing via UI - rpc_config_edit = fields.Text( - help="Configure RPC config via JSON. " - "Value must be a list of methods to disable " - "wrapped by a dict with key `disable`. " - "Eg: {'disable': ['search', 'do_this']}" - "To disable all methods, use `{'disable: ['all']}`", - inverse="_inverse_rpc_config_edit", - ) - - @api.depends("rpc_config_edit") - def _compute_rpc_config(self): - for rec in self: - rec.rpc_config = rec._load_rpc_config() - - def _inverse_rpc_config_edit(self): - for rec in self: - # Make sure options_edit is always readable - rec.rpc_config_edit = json.dumps( - rec.rpc_config or {}, indent=4, sort_keys=True - ) - - def _load_rpc_config(self): - return json.loads(self.rpc_config_edit or "{}") - - @tools.ormcache("model") - def _get_rpc_config(self, model): - rec = self._get(model) - return rec.rpc_config or {} diff --git a/addons/rpc_helper/patch.py b/addons/rpc_helper/patch.py deleted file mode 100644 index c3a0569..0000000 --- a/addons/rpc_helper/patch.py +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright 2022 Camptocamp SA -# @author: Simone Orsi -# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). - -import odoo -from odoo.exceptions import UserError -from odoo.tools.translate import _ - - -def protected__execute_cr(cr, uid, obj, method, *args, **kw): - # Same as original func in odoo.service.model.execute_cr - cr.reset() - recs = odoo.api.Environment(cr, uid, {}).get(obj) - if recs is None: - raise UserError(_("Object %s doesn't exist", obj)) - # custom code starts here - if not _rpc_allowed(recs, method): - raise UserError(_("RPC call on %s is not allowed", obj)) - return protected__execute_cr._orig__execute_cr(cr, uid, obj, method, *args, **kw) - - -def _rpc_allowed(recordset, method): - config = getattr(recordset, "_disable_rpc", None) - if config is None: - config = ( - recordset.env["ir.model"]._get_rpc_config(recordset._name).get("disable") - ) - if config is None: - return True - return "all" not in config and method not in config diff --git a/addons/rpc_helper/readme/CONFIGURE.rst b/addons/rpc_helper/readme/CONFIGURE.rst deleted file mode 100644 index 84347b5..0000000 --- a/addons/rpc_helper/readme/CONFIGURE.rst +++ /dev/null @@ -1,23 +0,0 @@ -Enable debug mode and go to "Technical -> Database Structure -> Models". - -Open the model that you like to configure and go to the tab "RPC config". - -There you see a text field which supports JSON configuration. - -The configuration is the same you can pass via decorator. -The only difference is that you have to wrap values in a dictionary -like `{"disable": [...values...]}`. - -To disable all calls:: - - { - "disable": ["all"], - } - -To disable only some methods:: - - { - "disable": ["create", "write", "another_method"], - } - -NOTE: on the resulting JSON will be automatically formatted on save for better readability. diff --git a/addons/rpc_helper/readme/CONTRIBUTORS.rst b/addons/rpc_helper/readme/CONTRIBUTORS.rst deleted file mode 100644 index f1c71bc..0000000 --- a/addons/rpc_helper/readme/CONTRIBUTORS.rst +++ /dev/null @@ -1 +0,0 @@ -* Simone Orsi diff --git a/addons/rpc_helper/readme/DESCRIPTION.rst b/addons/rpc_helper/readme/DESCRIPTION.rst deleted file mode 100644 index e5078d9..0000000 --- a/addons/rpc_helper/readme/DESCRIPTION.rst +++ /dev/null @@ -1 +0,0 @@ -Provide helpers to authorize RPC calls. diff --git a/addons/rpc_helper/readme/USAGE.rst b/addons/rpc_helper/readme/USAGE.rst deleted file mode 100644 index ff67524..0000000 --- a/addons/rpc_helper/readme/USAGE.rst +++ /dev/null @@ -1,24 +0,0 @@ -Via code -~~~~~~~~ - -Decorate an Odoo model class like this:: - - from odoo.addons.rpc_helper.decorator import disable_rpc - - @disable_rpc() - class AverageModel(models.Model): - _inherit = "avg.model" - -This will disable ALL calls. - -To selectively disable only some methods:: - - @disable_rpc("create", "write", "any_method") - class AverageModel(models.Model): - _inherit = "avg.model" - - -Via `ir.model` configuration -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -See "Configuration" section. diff --git a/addons/rpc_helper/rpc_test_example.py b/addons/rpc_helper/rpc_test_example.py deleted file mode 100644 index d48b9a7..0000000 --- a/addons/rpc_helper/rpc_test_example.py +++ /dev/null @@ -1,15 +0,0 @@ -"""Basic example script you can use to test your own models for real. -""" -from xmlrpc import client - -HOST = "127.0.0.1" -PORT = 8069 -DB_NAME = "odoodb" - -url = "http://%s:%d/xmlrpc/2/" % (HOST, PORT) -xmlrpc_common = client.ServerProxy(url + "common") -xmlrpc_db = client.ServerProxy(url + "db") -xmlrpc_object = client.ServerProxy(url + "object") - -uid = xmlrpc_common.login(DB_NAME, "admin", "admin") -res = xmlrpc_object.execute(DB_NAME, uid, "admin", "res.partner", "search", []) diff --git a/addons/rpc_helper/static/description/icon.png b/addons/rpc_helper/static/description/icon.png deleted file mode 100644 index 3a0328b..0000000 Binary files a/addons/rpc_helper/static/description/icon.png and /dev/null differ diff --git a/addons/rpc_helper/static/description/index.html b/addons/rpc_helper/static/description/index.html deleted file mode 100644 index db42144..0000000 --- a/addons/rpc_helper/static/description/index.html +++ /dev/null @@ -1,476 +0,0 @@ - - - - - - -Disable RPC - - - -
-

Disable RPC

- - -

Beta License: LGPL-3 OCA/server-tools Translate me on Weblate Try me on Runboat

-

Provide helpers to authorize RPC calls.

-

Table of contents

- -
-

Configuration

-

Enable debug mode and go to “Technical -> Database Structure -> Models”.

-

Open the model that you like to configure and go to the tab “RPC config”.

-

There you see a text field which supports JSON configuration.

-

The configuration is the same you can pass via decorator. -The only difference is that you have to wrap values in a dictionary -like {“disable”: […values…]}.

-

To disable all calls:

-
-{
-    "disable": ["all"],
-}
-
-

To disable only some methods:

-
-{
-    "disable": ["create", "write", "another_method"],
-}
-
-

NOTE: on the resulting JSON will be automatically formatted on save for better readability.

-
-
-

Usage

-
-

Via code

-

Decorate an Odoo model class like this:

-
-from odoo.addons.rpc_helper.decorator import disable_rpc
-
-@disable_rpc()
-class AverageModel(models.Model):
-    _inherit = "avg.model"
-
-

This will disable ALL calls.

-

To selectively disable only some methods:

-
-@disable_rpc("create", "write", "any_method")
-class AverageModel(models.Model):
-    _inherit = "avg.model"
-
-
-
-

Via ir.model configuration

-

See “Configuration” section.

-
-
-
-

Bug Tracker

-

Bugs are tracked on GitHub Issues. -In case of trouble, please check there if your issue has already been reported. -If you spotted it first, help us to smash it by providing a detailed and welcomed -feedback.

-

Do not contact contributors directly about support or help with technical issues.

-
-
-

Credits

-
-

Authors

-
    -
  • Camptocamp
  • -
-
- -
-

Maintainers

-

This module is maintained by the OCA.

-Odoo Community Association -

OCA, or the Odoo Community Association, is a nonprofit organization whose -mission is to support the collaborative development of Odoo features and -promote its widespread use.

-

Current maintainer:

-

simahawk

-

This module is part of the OCA/server-tools project on GitHub.

-

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

-
-
-
- - diff --git a/addons/rpc_helper/tests/__init__.py b/addons/rpc_helper/tests/__init__.py deleted file mode 100644 index c60563b..0000000 --- a/addons/rpc_helper/tests/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -from . import test_xmlrpc -from . import test_decorator diff --git a/addons/rpc_helper/tests/test_decorator.py b/addons/rpc_helper/tests/test_decorator.py deleted file mode 100644 index 1ee3ee5..0000000 --- a/addons/rpc_helper/tests/test_decorator.py +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright 2022 Camptocamp SA -# @author: Simone Orsi -# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). - - -import unittest - -from ..decorator import disable_rpc - - -@disable_rpc() -class All: - pass - - -@disable_rpc("create") -class One: - pass - - -@disable_rpc("create", "write") -class Multi: - pass - - -class TestDecorator(unittest.TestCase): - def test_all(self): - self.assertEqual(All._disable_rpc, ("all",)) - - def test_one(self): - self.assertEqual(One._disable_rpc, ("create",)) - - def test_multi(self): - self.assertEqual(Multi._disable_rpc, ("create", "write")) diff --git a/addons/rpc_helper/tests/test_xmlrpc.py b/addons/rpc_helper/tests/test_xmlrpc.py deleted file mode 100644 index bf18ea2..0000000 --- a/addons/rpc_helper/tests/test_xmlrpc.py +++ /dev/null @@ -1,77 +0,0 @@ -# Copyright 2022 Camptocamp SA -# @author: Simone Orsi -# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). - - -import json -import xmlrpc - -from odoo.tests import common - - -@common.tagged("post_install", "-at_install") -class TestXMLRPC(common.HttpCase): - @classmethod - def setUpClass(cls): - super().setUpClass() - cls.admin_uid = cls.env.ref("base.user_admin").id - - def _set_disable(self, val): - type(self.env["res.partner"])._disable_rpc = val - - def _set_disable_on_model(self, val): - self.env["ir.model"]._get("res.partner").rpc_config_edit = json.dumps( - {"disable": val} - ) - self.env.flush_all() - - def tearDown(self): - klass = type(self.env["res.partner"]) - if hasattr(klass, "_disable_rpc"): - delattr(klass, "_disable_rpc") - super().tearDown() - - def _rpc_call(self, method, vals=None): - o = self.xmlrpc_object - db_name = common.get_db_name() - return o.execute( - db_name, self.admin_uid, "admin", "res.partner", method, vals or [] - ) - - def test_xmlrpc_search_normal(self): - res = self._rpc_call("search") - self.assertTrue(isinstance(res, list)) - - def test_xmlrpc_all_blocked(self): - self._set_disable(("all",)) - msg = "RPC call on res.partner is not allowed" - with self.assertRaisesRegex(xmlrpc.client.Fault, msg): - self._rpc_call("search") - - with self.assertRaisesRegex(xmlrpc.client.Fault, msg): - self._rpc_call("create", vals=[{"name": "Foo"}]) - - def test_xmlrpc_can_search_create_blocked(self): - self._set_disable(("create",)) - self._rpc_call("search") - - msg = "RPC call on res.partner is not allowed" - with self.assertRaisesRegex(xmlrpc.client.Fault, msg): - self._rpc_call("create", vals=[{"name": "Foo"}]) - - def test_xmlrpc_all_blocked__ir_model(self): - self._set_disable_on_model(("all",)) - msg = "RPC call on res.partner is not allowed" - with self.assertRaisesRegex(xmlrpc.client.Fault, msg): - self._rpc_call("search") - - with self.assertRaisesRegex(xmlrpc.client.Fault, msg): - self._rpc_call("create", vals=[{"name": "Foo"}]) - - def test_xmlrpc_can_search_create_blocked__ir_model(self): - self._set_disable_on_model(("create",)) - self._rpc_call("search") - - msg = "RPC call on res.partner is not allowed" - with self.assertRaisesRegex(xmlrpc.client.Fault, msg): - self._rpc_call("create", vals=[{"name": "Foo"}]) diff --git a/addons/rpc_helper/views/ir_model_views.xml b/addons/rpc_helper/views/ir_model_views.xml deleted file mode 100644 index d98b45c..0000000 --- a/addons/rpc_helper/views/ir_model_views.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - rpc_helper view_model_form - ir.model - - - - - - - - - -