[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
This commit is contained in:
parent
64e1c28e35
commit
bd9cbdfc41
|
@ -33,6 +33,7 @@ import openerp
|
||||||
import openerp.modules.registry
|
import openerp.modules.registry
|
||||||
from openerp.addons.base.ir.ir_qweb import AssetsBundle, QWebTemplateNotFound
|
from openerp.addons.base.ir.ir_qweb import AssetsBundle, QWebTemplateNotFound
|
||||||
from openerp.modules import get_module_resource
|
from openerp.modules import get_module_resource
|
||||||
|
from openerp.service import model as service_model
|
||||||
from openerp.tools import topological_sort
|
from openerp.tools import topological_sort
|
||||||
from openerp.tools.translate import _
|
from openerp.tools.translate import _
|
||||||
from openerp.tools import ustr
|
from openerp.tools import ustr
|
||||||
|
@ -933,7 +934,10 @@ class DataSet(http.Controller):
|
||||||
if method.startswith('_'):
|
if method.startswith('_'):
|
||||||
raise Exception("Access Denied: Underscore prefixed methods cannot be remotely called")
|
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")
|
@http.route('/web/dataset/call', type='json', auth="user")
|
||||||
def call(self, model, method, args, domain_id=None, context_id=None):
|
def call(self, model, method, args, domain_id=None, context_id=None):
|
||||||
|
|
Loading…
Reference in New Issue