From f5bfa3d3b653c8ec8a9a1820eeff995a7f954ca9 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Fri, 21 Apr 2017 08:48:35 +0200 Subject: [FIX] web: FormView: don't modify record's context Before this rev., some keys were added to the context of a record if there were x2many fields in the form view with a context defined on their node (containing *_view_ref keys, specifying the fields_view to load to display the relational data). Those keys should not be added to the main record's context, and it may cause errors (e.g. click on the 'Procurements' stat button in the Product form view). --- addons/web/static/src/js/views/abstract_view.js | 2 ++ addons/web/static/src/js/views/form/form_view.js | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'addons/web/static/src/js/views') diff --git a/addons/web/static/src/js/views/abstract_view.js b/addons/web/static/src/js/views/abstract_view.js index e1066e56e92..fdb029da6c3 100644 --- a/addons/web/static/src/js/views/abstract_view.js +++ b/addons/web/static/src/js/views/abstract_view.js @@ -102,6 +102,8 @@ var AbstractView = Class.extend({ if (params.modelName) { this.loadParams.modelName = params.modelName; } + + this.userContext = params.userContext; }, //-------------------------------------------------------------------------- diff --git a/addons/web/static/src/js/views/form/form_view.js b/addons/web/static/src/js/views/form/form_view.js index 2a1eb2b4da5..4fff1a74ee4 100644 --- a/addons/web/static/src/js/views/form/form_view.js +++ b/addons/web/static/src/js/views/form/form_view.js @@ -64,16 +64,16 @@ var FormView = BasicView.extend({ attrs.limit = attrs.mode === "tree" ? 80 : 40; if (attrs.Widget.prototype.useSubview && !(attrs.invisible && JSON.parse(attrs.invisible)) && !attrs.views[attrs.mode]) { + var context = {}; var regex = /'([a-z]*_view_ref)' *: *'(.*?)'/g; var matches; while (matches = regex.exec(attrs.context)) { - self.loadParams.context[matches[1]] = matches[2]; + context[matches[1]] = matches[2]; } defs.push(parent.loadViews( field.relation, - new Context(self.loadParams.context), - [[null, attrs.mode === 'tree' ? 'list' : attrs.mode]], - {}) + new Context(context, self.userContext), + [[null, attrs.mode === 'tree' ? 'list' : attrs.mode]]) .then(function (views) { for (var viewName in views) { attrs.views[viewName] = views[viewName]; -- cgit v1.2.3