From 1f5038dd14d0dcb0fbda1df32a7c5269c7d5f080 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 26 Jul 2017 23:26:09 +0200 Subject: [PATCH] Use right form view in Many2One and WinSearch The first view which is a tree must be removed from the view ids as mode of the screen is form only. issue6510 review35501002 --- src/view/form.js | 7 ++++++- src/window.js | 11 ++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/view/form.js b/src/view/form.js index 8ab29c57d2..15455592b6 100644 --- a/src/view/form.js +++ b/src/view/form.js @@ -1884,11 +1884,16 @@ function eval_pyson(value){ get_screen: function() { var domain = this.field().get_domain(this.record()); var context = this.field().get_context(this.record()); + var view_ids = (this.attributes.view_ids || '').split(','); + if (!jQuery.isEmptyObject(view_ids)) { + // Remove the first tree view as mode is form only + view_ids.shift(); + } return new Sao.Screen(this.get_model(), { 'context': context, 'domain': domain, 'mode': ['form'], - 'view_ids': (this.attributes.view_ids || '').split(','), + 'view_ids': view_ids, 'views_preload': this.attributes.views, 'readonly': this._readonly }); diff --git a/src/window.js b/src/window.js index ea950e493c..756f7a4bfa 100644 --- a/src/window.js +++ b/src/window.js @@ -470,6 +470,8 @@ this.model_name = model; this.domain = kwargs.domain || []; this.context = kwargs.context || {}; + this.view_ids = kwargs.view_ids; + this.views_preload = views_preload; this.sel_multi = kwargs.sel_multi; this.callback = callback; this.title = kwargs.title || ''; @@ -540,10 +542,17 @@ this.screen.search_filter(); return; } else if (response_id == 'RESPONSE_ACCEPT') { + var view_ids = jQuery.extend([], this.view_ids); + if (!jQuery.isEmptyObject(view_ids)) { + // Remove the first tree view as mode is form only + view_ids.shift(); + } var screen = new Sao.Screen(this.model_name, { domain: this.domain, context: this.context, - mode: ['form'] + mode: ['form'], + view_ids: view_ids, + views_preload: this.views_preload, }); var callback = function(result) {