From 5197e377099eedea511dd6277381e4d36e3cdf28 Mon Sep 17 00:00:00 2001 From: GuillemCForgeFlow Date: Tue, 29 Oct 2024 13:27:07 +0100 Subject: [PATCH] [BKP][ADD]rpc_helper Backport from v14: https://github.com/OCA/server-tools/tree/14.0/rpc_helper --- rpc_helper/__manifest__.py | 2 +- rpc_helper/patch.py | 4 ++-- rpc_helper/readme/CONTRIBUTORS.rst | 1 + rpc_helper/tests/test_xmlrpc.py | 9 ++++----- rpc_helper/views/ir_model_views.xml | 6 +++--- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/rpc_helper/__manifest__.py b/rpc_helper/__manifest__.py index 96ffff4ed93..44fa3155b68 100644 --- a/rpc_helper/__manifest__.py +++ b/rpc_helper/__manifest__.py @@ -5,7 +5,7 @@ { "name": "Disable RPC", "summary": """Helpers for disabling RPC calls""", - "version": "14.0.1.2.0", + "version": "13.0.1.0.0", "development_status": "Beta", "license": "LGPL-3", "website": "https://github.com/OCA/server-tools", diff --git a/rpc_helper/patch.py b/rpc_helper/patch.py index 3eb987da891..d7488d8c80d 100644 --- a/rpc_helper/patch.py +++ b/rpc_helper/patch.py @@ -12,10 +12,10 @@ def protected__execute_cr(cr, uid, obj, method, *args, **kw): odoo.api.Environment.reset() # clean cache etc if we retry the same transaction recs = odoo.api.Environment(cr, uid, {}).get(obj) if recs is None: - raise UserError(_("Object %s doesn't exist", obj)) + raise UserError(_(f"Object {obj} doesn't exist")) # custom code starts here if not _rpc_allowed(recs, method): - raise UserError(_("RPC call on %s is not allowed", obj)) + raise UserError(_(f"RPC call on {obj} is not allowed")) return protected__execute_cr._orig__execute_cr(cr, uid, obj, method, *args, **kw) diff --git a/rpc_helper/readme/CONTRIBUTORS.rst b/rpc_helper/readme/CONTRIBUTORS.rst index f1c71bce186..37423d21eef 100644 --- a/rpc_helper/readme/CONTRIBUTORS.rst +++ b/rpc_helper/readme/CONTRIBUTORS.rst @@ -1 +1,2 @@ * Simone Orsi +* Guillem Casassas diff --git a/rpc_helper/tests/test_xmlrpc.py b/rpc_helper/tests/test_xmlrpc.py index e442fbe2a44..3b9358aac80 100644 --- a/rpc_helper/tests/test_xmlrpc.py +++ b/rpc_helper/tests/test_xmlrpc.py @@ -10,11 +10,10 @@ @common.tagged("post_install", "-at_install") -class TestXMLRPC(common.HttpSavepointCase): - @classmethod - def setUpClass(cls): - super().setUpClass() - cls.admin_uid = cls.env.ref("base.user_admin").id +class TestXMLRPC(common.HttpCase): + def setUp(self): + super().setUp() + self.admin_uid = self.env.ref("base.user_admin").id def _set_disable(self, val): type(self.env["res.partner"])._disable_rpc = val diff --git a/rpc_helper/views/ir_model_views.xml b/rpc_helper/views/ir_model_views.xml index d98b45c82e2..0e1311f3be4 100644 --- a/rpc_helper/views/ir_model_views.xml +++ b/rpc_helper/views/ir_model_views.xml @@ -9,12 +9,12 @@ ir.model - + -