-
-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX] shopfloor_base: Manage correctly parameters to the next call stack
- Loading branch information
1 parent
7cbea89
commit 2d946b7
Showing
4 changed files
with
30 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
~~~~~~ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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( | ||
|
@@ -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 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
~~~~~~ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters