From ab85e9594651fd33ffd2747f4d3c5b360e7c7922 Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Wed, 20 Jun 2018 09:54:42 +0200 Subject: [PATCH] [FIX] ir_qweb: remove browse records from context The context is send to qweb as option, the options are converted into a frozen dict, the browse records can have a closer cursor, takes the place in the cache, and raise and exception in qweb (because contact try to json.dumps options for multi-edition feature in web_editor. opw-1859848 --- odoo/addons/base/ir/ir_qweb/ir_qweb.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/odoo/addons/base/ir/ir_qweb/ir_qweb.py b/odoo/addons/base/ir/ir_qweb/ir_qweb.py index 543029d5f82..05c3f3f87d7 100644 --- a/odoo/addons/base/ir/ir_qweb/ir_qweb.py +++ b/odoo/addons/base/ir/ir_qweb/ir_qweb.py @@ -51,7 +51,21 @@ class IrQWeb(models.AbstractModel, QWeb): if method.startswith('render_'): _logger.warning("Unused method '%s' is found in ir.qweb." % method) - context = dict(self.env.context, dev_mode='qweb' in tools.config['dev_mode']) + def jsonable(val): + try: + json.dumps(val) + return True + except Exception: + return False + + context = { + key: val + for key, val in self.env.context.items() + if isinstance(key, pycompat.string_types) and not key.startswith('_') + if jsonable(val) + } + context['dev_mode'] = 'qweb' in tools.config['dev_mode'] + # context = dict(self.env.context, dev_mode='qweb' in tools.config['dev_mode']) context.update(options) return super(IrQWeb, self).render(id_or_xml_id, values=values, **context)