From 79f137f342109c2ef5ca3ebc491607a1ea5de549 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Gonz=C3=A1lez?= Date: Thu, 8 Feb 2018 16:49:16 +0000 Subject: [PATCH] [FIX] base: Avoid error when keep_query is used outside an httprequest context When the utility method `keep_query()` is used outside an httprequest context (e.g. rendering a template from a unittest) the following exception is throwng: `RuntimeError: object unbound` The above exception is caused by the method trying to retrieve parameters from the HTTP request, even if the request object is unbownd. This change ensures those parameters are retrieved only when exists, making possible to use it outside the web client Closes #18841 Closes #22942 Closes opw-815322 --- openerp/addons/base/ir/ir_ui_view.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openerp/addons/base/ir/ir_ui_view.py b/openerp/addons/base/ir/ir_ui_view.py index a52574a2710..8a799789123 100644 --- a/openerp/addons/base/ir/ir_ui_view.py +++ b/openerp/addons/base/ir/ir_ui_view.py @@ -50,7 +50,7 @@ def keep_query(*keep_params, **additional_params): if not keep_params and not additional_params: keep_params = ('*',) params = additional_params.copy() - qs_keys = request.httprequest.args.keys() + qs_keys = request.httprequest.args.keys() if request else [] for keep_param in keep_params: for param in fnmatch.filter(qs_keys, keep_param): if param not in additional_params and param in qs_keys: