Skip to content

Commit

Permalink
[MIG] rpc_helper: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
natuan9 committed Nov 21, 2024
1 parent 455dc4a commit 4afc7f9
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 14 deletions.
14 changes: 12 additions & 2 deletions rpc_helper/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ To disable all calls:
::

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

To disable only some methods:

::

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

NOTE: on the resulting JSON will be automatically formatted on save for
Expand Down Expand Up @@ -122,6 +122,16 @@ Contributors

- Simone Orsi <[email protected]>

Trobz

- Tuan Nguyen <[email protected]>

Other credits
-------------

The migration of this module from 16.0 to 18.0 was financially supported
by Camptocamp.

Maintainers
-----------

Expand Down
2 changes: 1 addition & 1 deletion rpc_helper/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{
"name": "Disable RPC",
"summary": """Helpers for disabling RPC calls""",
"version": "16.0.1.0.0",
"version": "18.0.1.0.0",
"development_status": "Beta",
"license": "LGPL-3",
"website": "https://github.com/OCA/server-tools",
Expand Down
8 changes: 4 additions & 4 deletions rpc_helper/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@

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)
env = odoo.api.Environment(cr, uid, {})
recs = env.get(obj)
if recs is None:
raise UserError(_("Object %s doesn't exist", obj))
raise UserError(env._("Object %s doesn't exist", obj))

Check warning on line 15 in rpc_helper/patch.py

View check run for this annotation

Codecov / codecov/patch

rpc_helper/patch.py#L15

Added line #L15 was not covered by tests
# custom code starts here
if not _rpc_allowed(recs, method):
raise UserError(_("RPC call on %s is not allowed", obj))
raise UserError(env._("RPC call on %s is not allowed", obj))
return protected__execute_cr._orig__execute_cr(cr, uid, obj, method, *args, **kw)


Expand Down
4 changes: 2 additions & 2 deletions rpc_helper/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ difference is that you have to wrap values in a dictionary like
To disable all calls:

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

To disable only some methods:

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

NOTE: on the resulting JSON will be automatically formatted on save for
Expand Down
3 changes: 3 additions & 0 deletions rpc_helper/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
- Simone Orsi \<<[email protected]>\>

Trobz
- Tuan Nguyen \<<[email protected]>\>
1 change: 1 addition & 0 deletions rpc_helper/readme/CREDITS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The migration of this module from 16.0 to 18.0 was financially supported by Camptocamp.
18 changes: 14 additions & 4 deletions rpc_helper/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,8 @@ <h1 class="title">Disable RPC</h1>
<li><a class="reference internal" href="#credits" id="toc-entry-6">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-7">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-8">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-9">Maintainers</a></li>
<li><a class="reference internal" href="#other-credits" id="toc-entry-9">Other credits</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-10">Maintainers</a></li>
</ul>
</li>
</ul>
Expand All @@ -401,13 +402,13 @@ <h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
<p>To disable all calls:</p>
<pre class="literal-block">
{
&quot;disable&quot;: [&quot;all&quot;],
&quot;disable&quot;: [&quot;all&quot;]
}
</pre>
<p>To disable only some methods:</p>
<pre class="literal-block">
{
&quot;disable&quot;: [&quot;create&quot;, &quot;write&quot;, &quot;another_method&quot;],
&quot;disable&quot;: [&quot;create&quot;, &quot;write&quot;, &quot;another_method&quot;]
}
</pre>
<p>NOTE: on the resulting JSON will be automatically formatted on save for
Expand Down Expand Up @@ -459,9 +460,18 @@ <h2><a class="toc-backref" href="#toc-entry-8">Contributors</a></h2>
<ul class="simple">
<li>Simone Orsi &lt;<a class="reference external" href="mailto:simone.orsi&#64;camptocamp.com">simone.orsi&#64;camptocamp.com</a>&gt;</li>
</ul>
<p>Trobz</p>
<ul class="simple">
<li>Tuan Nguyen &lt;<a class="reference external" href="mailto:tuanna&#64;trobz.com">tuanna&#64;trobz.com</a>&gt;</li>
</ul>
</div>
<div class="section" id="other-credits">
<h2><a class="toc-backref" href="#toc-entry-9">Other credits</a></h2>
<p>The migration of this module from 16.0 to 18.0 was financially supported
by Camptocamp.</p>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-9">Maintainers</a></h2>
<h2><a class="toc-backref" href="#toc-entry-10">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
Expand Down
2 changes: 1 addition & 1 deletion rpc_helper/views/ir_model_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<field
name="rpc_config_edit"
groups="base.group_no_one"
widget="ace"
widget="code"
/>
</page>
</xpath>
Expand Down

0 comments on commit 4afc7f9

Please sign in to comment.