From ea72b1ff32aaf8faf8d167b4970aea0f68f9ae84 Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Thu, 30 Sep 2021 11:43:02 +0000 Subject: [PATCH] [FIX] base: warnings with context key 'validation_views' The context key 'validation_views' is used by ir.ui.view to determine what parts of a view arch must be validated. Its associated value is either True or a recordset, and having those types leads to unexpected warnings when creating environments. Before creating a new environment, the class Environment looks for an existing environment with the given parameters: cr, uid, context, su. The comparison of a context where 'validation_views' is a recordset with another context where 'validation_views' is True, generates the warning "unsupported operand type(s)"... We avoid this situation by using ids instead of a recordset for the value of the validation context key. closes odoo/odoo#77747 X-original-commit: 210cd625a052a4d3c230a93bcba644c9a31e67ab Signed-off-by: Raphael Collet (rco) --- odoo/addons/base/models/ir_ui_view.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/odoo/addons/base/models/ir_ui_view.py b/odoo/addons/base/models/ir_ui_view.py index 0f24cfcf7ea..58aed3a3c4e 100644 --- a/odoo/addons/base/models/ir_ui_view.py +++ b/odoo/addons/base/models/ir_ui_view.py @@ -410,7 +410,7 @@ actual arch. # Sanity checks: the view should not break anything upon rendering! # Any exception raised below will cause a transaction rollback. partial_validation = self.env.context.get('ir_ui_view_partial_validation') - self = self.with_context(validate_views=(self if partial_validation else True)) + self = self.with_context(validate_view_ids=(self._ids if partial_validation else True)) for view in self: try: @@ -798,18 +798,18 @@ actual arch. :param Element arch: an optional modifying architecture from inheriting view ``view`` """ - # validate_views is either falsy (no validation), True (full validation) - # or a recordset (partial validation) - validate_views = self.env.context.get('validate_views') - if not validate_views: + # validate_view_ids is either falsy (no validation), True (full + # validation) or a collection of ids (partial validation) + validate_view_ids = self.env.context.get('validate_view_ids') + if not validate_view_ids: return - if validate_views is True or self in validate_views: + if validate_view_ids is True or self.id in validate_view_ids: # optimization, flag the root node combined_arch.set('__validate__', '1') return - if view is None or view not in validate_views: + if view is None or view.id not in validate_view_ids: return for node in arch.xpath('//*[@position]'):