From 8209368b020a620e4f7287091cbe46cb70b6701e Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Tue, 13 Oct 2015 17:12:34 +0200 Subject: [PATCH] [FIX] web: current transaction is aborted This reverts commit bd9cbdfc41584c829be48f6a30abb7be3a8a63fb. The above revision solved the SQL constraints not being translated when raised. They were not translated because the context, containing the lang, was not located as expected in the `kwargs` dict. While it solved this issue, it had as side-effect to raise `current transaction is aborted, commands ignored until end of transaction block` errors more often when using the web client. This can be explained by the double check, when the first check raised this error - which can happen, e.g. when the cursor is closed, there is a retry mechanism in such cases - and by the fact the transaction was not rollbacked. This issue could have been solved as well by rollbacking the transaction, but it is regarded as not-so-clean. Therefore, to solve this issue, while still having the SQL constraints translated, we apply the second patch proposed in bd9cbdfc41584c829be48f6a30abb7be3a8a63fb commit message, which is not-so-clean as well, but which is a proper solution. opw-651393 --- addons/web/controllers/main.py | 6 +----- openerp/service/model.py | 7 ++++++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index c598e224bba..9d3993a24c9 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -33,7 +33,6 @@ 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 @@ -934,10 +933,7 @@ class DataSet(http.Controller): if method.startswith('_'): raise Exception("Access Denied: Underscore prefixed methods cannot be remotely called") - @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) + return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs) @http.route('/web/dataset/call', type='json', auth="user") def call(self, model, method, args, domain_id=None, context_id=None): diff --git a/openerp/service/model.py b/openerp/service/model.py index 11054f237d7..bace80bb896 100644 --- a/openerp/service/model.py +++ b/openerp/service/model.py @@ -54,7 +54,12 @@ def check(f): if args and isinstance(args[-1], dict): ctx = args[-1] elif isinstance(kwargs, dict): - ctx = kwargs.get('context', {}) + if 'context' in kwargs: + ctx = kwargs['context'] + elif 'kwargs' in kwargs: + # http entry points such as call_kw() + ctx = kwargs['kwargs'].get('context') + uid = 1 if args and isinstance(args[0], (long, int)):