Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
f1f889e
Add rpc_helper
simahawk Feb 18, 2022
e735350
[ADD] icon.png
OCA-git-bot Feb 18, 2022
bdf78e4
rpc_helper: add config via UI
simahawk Feb 21, 2022
c2e818c
rpc_helper 14.0.1.1.0
OCA-git-bot Mar 4, 2022
4b65dc5
Added translation using Weblate (Spanish (Argentina))
ibuioli Sep 2, 2022
46fc8ac
rpc_helper: fix readme
simahawk Mar 7, 2023
9b05f6c
rpc_helper 14.0.1.1.1
OCA-git-bot Mar 7, 2023
adaadbf
rpc_helper: migrate to v16
simahawk Feb 16, 2023
e729bf2
Translated using Weblate (Spanish)
Ivorra78 Aug 27, 2023
cc05e13
[UPD] README.rst
OCA-git-bot Feb 18, 2022
56138d3
Translated using Weblate (Italian)
mymage Jan 2, 2024
1a643f0
[UPD] Update rpc_helper.pot
oca-travis Feb 18, 2022
6ae8881
Update translation files
weblate May 10, 2023
c34bff7
Translated using Weblate (Spanish (Argentina))
ibuioli Aug 13, 2024
b473e68
Translated using Weblate (Italian)
mymage May 28, 2024
5ae9004
[IMP] rpc_helper: pre-commit auto fixes
natuan9 Nov 20, 2024
364c236
[MIG] rpc_helper: Migration to 18.0
natuan9 Nov 20, 2024
25543b4
[UPD] Update rpc_helper.pot
Dec 3, 2024
8405ee9
[BOT] post-merge updates
OCA-git-bot Dec 3, 2024
21d84fd
Update translation files
weblate Dec 3, 2024
006d032
[FIX] rpc_helper: mute warning logs to keep checklog-odoo happy
StefanRijnhart Feb 5, 2025
40bbbac
[BOT] post-merge updates
OCA-git-bot Feb 7, 2025
14e6c6c
[UPD] Update rpc_helper.pot
Mar 16, 2025
2c51083
Update translation files
weblate Mar 16, 2025
6bf0884
[REF] rpc_helper: adapt test to new Odoo test patch checker
StefanRijnhart Feb 19, 2026
2c55d2f
[BOT] post-merge updates
OCA-git-bot Feb 20, 2026
88bc0db
[MIG] rpc_helper: Migration to 19.0
JasminSForgeFlow Mar 5, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
156 changes: 156 additions & 0 deletions rpc_helper/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

===========
Disable RPC
===========

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:d71c6c86a2635b277c84c2a0eeeb2fd97802d45117fe1204a3314cc158f09b6d
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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/license-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/19.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-19-0/server-tools-19-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=19.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 <https://github.com/OCA/server-tools/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 <https://github.com/OCA/server-tools/issues/new?body=module:%20rpc_helper%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Credits
=======

Authors
-------

* Camptocamp

Contributors
------------

- Simone Orsi <simone.orsi@camptocamp.com>

Trobz

- Tuan Nguyen <tuanna@trobz.com>

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 <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-simahawk|

This module is part of the `OCA/server-tools <https://github.com/OCA/server-tools/tree/19.0/rpc_helper>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions rpc_helper/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models
from .hooks import post_load_hook
17 changes: 17 additions & 0 deletions rpc_helper/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2022 Camptocamp SA
# @author: Simone Orsi <simone.orsi@camptocamp.com>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

{
"name": "Disable RPC",
"summary": """Helpers for disabling RPC calls""",
"version": "19.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",
}
19 changes: 19 additions & 0 deletions rpc_helper/decorator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2022 Camptocamp SA
# @author: Simone Orsi <simone.orsi@camptocamp.com>
# 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
22 changes: 22 additions & 0 deletions rpc_helper/hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2022 Camptocamp SA
# @author: Simone Orsi <simone.orsi@camptocamp.com>
# 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()
66 changes: 66 additions & 0 deletions rpc_helper/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# 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 <informatica@totmaterial.es>\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,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,name:rpc_helper.model_ir_model
msgid "Models"
msgstr "Modelos"

#. module: rpc_helper
#. odoo-python
#: code:addons/rpc_helper/patch.py:0
msgid "Object %s doesn't exist"
msgstr "El objeto %s no existe"

#. module: rpc_helper
#. odoo-python
#: code:addons/rpc_helper/patch.py:0
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"
103 changes: 103 additions & 0 deletions rpc_helper/i18n/es_AR.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# 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 <ibuioli@gmail.com>\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,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,name:rpc_helper.model_ir_model
msgid "Models"
msgstr "Modelos"

#. module: rpc_helper
#. odoo-python
#: code:addons/rpc_helper/patch.py:0
msgid "Object %s doesn't exist"
msgstr "El Objeto %s no existe"

#. module: rpc_helper
#. odoo-python
#: code:addons/rpc_helper/patch.py:0
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"

#~ msgid "Changeset Changes"
#~ msgstr "Cambios del Conjunto de Cambios"

#~ msgid "Changesets"
#~ msgstr "Conjunto de Cambios"

#~ msgid "Count Changesets"
#~ msgstr "Cuenta de Configuración de Cambios"

#~ msgid "Count Pending Changeset Changes"
#~ msgstr "Cuenta de los Cambios Pendientes de los Conjuntos de Cambios"

#~ msgid "Count Pending Changesets"
#~ msgstr "Cuenta de los Conjuntos de Cambios Pendientes"

#~ msgid "The number of pending changes of this record"
#~ msgstr "El número de los cambios pendientes de este registro"

#~ msgid "The number of pending changesets of this record"
#~ msgstr ""
#~ "El número de las configuraciones de cambios pendientes de este registro"

#~ msgid "The overall number of changesets of this record"
#~ msgstr "El número total de conjuntos de cambios de este registro"

#~ 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"
Loading
Loading