diff options
| author | Denis Ledoux <dle@odoo.com> | 2015-09-04 12:57:18 +0200 |
|---|---|---|
| committer | Denis Ledoux <dle@odoo.com> | 2015-09-04 12:58:00 +0200 |
| commit | bd9cbdfc41584c829be48f6a30abb7be3a8a63fb (patch) | |
| tree | ced9c62e4db3e659ce9e32a39aeec6a5d3cad22f | |
| parent | 64e1c28e358ec06a7683249fd7fae1ba631c1933 (diff) | |
[FIX] web: sql constraint translation
The `check` decorator expects the context to be in the `kwargs`
or to be the last arguments of the method.
The `call_kw` route, which is decorated by the `check` decorator,
like every route,
expands its kwargs arguments.
Therefore, once in the `check` decorator,
the context is located in the `kwargs` key
of the kwargs.
(More simply, instead of
`kwargs.get('context', {})`
it's
`kwargs.get('kwargs', {}).get('context', {})`
As the context is not retrieved correctly,
the lang is not set correctly either,
and the sql constraints were not translated.
In 7.0, it worked, because there was a double
check, as the call_kw was called trough an rpc
(`dispatch_rpc`) call,
which was decorated by the `check` as well.
As a fix for 8.0, we apply the same logic,
we perform a double check, with an indirection.
The check decorator should probably be
refactored, but this cannot be done
in a stable release such as 8.0.
Closes #3634
| -rw-r--r-- | addons/web/controllers/main.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index 8e844e816c7..6c6c9f1fe57 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -33,6 +33,7 @@ import openerp import openerp.modules.registry from openerp.addons.base.ir.ir_qweb import AssetsBundle, QWebTemplateNotFound from openerp.modules import get_module_resource +from openerp.service import model as service_model from openerp.tools import topological_sort from openerp.tools.translate import _ from openerp.tools import ustr @@ -933,7 +934,10 @@ class DataSet(http.Controller): if method.startswith('_'): raise Exception("Access Denied: Underscore prefixed methods cannot be remotely called") - return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs) + @service_model.check + def checked_call(__dbname, *args, **kwargs): + return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs) + return checked_call(request.db, *args, **kwargs) @http.route('/web/dataset/call', type='json', auth="user") def call(self, model, method, args, domain_id=None, context_id=None): |
