Skip to content

Commit

Permalink
[FIX] shopfloor_base: Manage correctly parameters to the next call stack
Browse files Browse the repository at this point in the history
  • Loading branch information
rousseldenis committed Feb 29, 2024
1 parent 7cbea89 commit 2d946b7
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
2 changes: 2 additions & 0 deletions shopfloor_base/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ Contributors
* Benoit Guillot <[email protected]>
* Thierry Ducrest <[email protected]>
* Michael Tietz (MT Software) <[email protected]>
* Denis Roussel <[email protected]>
* Laurent Mignon <[email protected]>

Design
~~~~~~
Expand Down
24 changes: 23 additions & 1 deletion shopfloor_base/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@
# @author Simone Orsi <[email protected]>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).

import json
import logging

from werkzeug.exceptions import BadRequest

from odoo.http import request

from odoo.addons.base_rest.controllers.main import RestController

_logger = logging.getLogger(__name__)


class ShopfloorController(RestController):
def _process_endpoint(
Expand All @@ -25,10 +32,25 @@ def _process_endpoint(
collection = collection or request.env["shopfloor.app"].browse(app_id)
# TODO: in base_rest `*args` is passed based on
# the type of route (eg: /<int:id>/update)
params = kwargs
# This in order to be compliant with recent Odoo changes
try:
httprequest = request._HTTPRequest__wrapped
except AttributeError:
httprequest = request.httprequest
if httprequest.mimetype == "application/json":
data = httprequest.get_data().decode(httprequest.charset)
if data:
try:
params.update(json.loads(data))
except (ValueError, json.decoder.JSONDecodeError) as e:
msg = "Invalid JSON data: %s" % str(e)
_logger.info("%s: %s", request.httprequest.path, msg)
raise BadRequest(msg) from e
return self._process_method(
service_name,
service_method_name,
*args,
collection=collection,
params=kwargs
params=params
)
2 changes: 2 additions & 0 deletions shopfloor_base/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* Benoit Guillot <[email protected]>
* Thierry Ducrest <[email protected]>
* Michael Tietz (MT Software) <[email protected]>
* Denis Roussel <[email protected]>
* Laurent Mignon <[email protected]>

Design
~~~~~~
Expand Down
3 changes: 3 additions & 0 deletions shopfloor_base/static/description/index.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
Expand Down Expand Up @@ -482,6 +483,8 @@ <h2><a class="toc-backref" href="#toc-entry-13">Contributors</a></h2>
<li>Benoit Guillot &lt;<a class="reference external" href="mailto:benoit.guillot&#64;akretion.com">benoit.guillot&#64;akretion.com</a>&gt;</li>
<li>Thierry Ducrest &lt;<a class="reference external" href="mailto:thierry.ducrest&#64;camptocamp.com">thierry.ducrest&#64;camptocamp.com</a>&gt;</li>
<li>Michael Tietz (MT Software) &lt;<a class="reference external" href="mailto:mtietz&#64;mt-software.de">mtietz&#64;mt-software.de</a>&gt;</li>
<li>Denis Roussel &lt;<a class="reference external" href="mailto:denis.roussel&#64;acsone.eu">denis.roussel&#64;acsone.eu</a>&gt;</li>
<li>Laurent Mignon &lt;<a class="reference external" href="mailto:laurent.mignon&#64;acsone.eu">laurent.mignon&#64;acsone.eu</a>&gt;</li>
</ul>
</div>
<div class="section" id="design">
Expand Down

0 comments on commit 2d946b7

Please sign in to comment.