From 71faf9f652ff53e770028252c2e5150e92a65b3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 26 Jul 2017 23:25:21 +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 review40531002 --- tryton/gui/window/view_form/view/form_gtk/many2many.py | 6 ++---- tryton/gui/window/view_form/view/form_gtk/many2one.py | 4 +++- tryton/gui/window/win_search.py | 7 ++++++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/tryton/gui/window/view_form/view/form_gtk/many2many.py b/tryton/gui/window/view_form/view/form_gtk/many2many.py index 657ef008db..be9b828976 100644 --- a/tryton/gui/window/view_form/view/form_gtk/many2many.py +++ b/tryton/gui/window/view_form/view/form_gtk/many2many.py @@ -176,10 +176,8 @@ class Many2Many(Widget): if add_remove: domain = [domain, add_remove] context = self.field.get_context(self.record) - view_ids = self.attrs.get('view_ids', '').split(',') - if view_ids: - # Remove the first tree view as mode is form only - view_ids.pop(0) + # Remove the first tree view as mode is form only + view_ids = self.attrs.get('view_ids', '').split(',')[1:] return Screen(self.attrs['relation'], domain=domain, view_ids=view_ids, mode=['form'], views_preload=self.attrs.get('views', {}), diff --git a/tryton/gui/window/view_form/view/form_gtk/many2one.py b/tryton/gui/window/view_form/view/form_gtk/many2one.py index 248f10d2e0..5c82833e6c 100644 --- a/tryton/gui/window/view_form/view/form_gtk/many2one.py +++ b/tryton/gui/window/view_form/view/form_gtk/many2one.py @@ -152,8 +152,10 @@ class Many2One(Widget): def get_screen(self): domain = self.field.domain_get(self.record) context = self.field.get_context(self.record) + # Remove first tree view as mode is form only + view_ids = self.attrs.get('view_ids', '').split(',')[1:] return Screen(self.get_model(), domain=domain, context=context, - mode=['form'], view_ids=self.attrs.get('view_ids', '').split(','), + mode=['form'], view_ids=view_ids, views_preload=self.attrs.get('views', {}), readonly=self._readonly, exclude_field=self.attrs.get('relation_field')) diff --git a/tryton/gui/window/win_search.py b/tryton/gui/window/win_search.py index 5acf72cb4e..ab9d70d69e 100644 --- a/tryton/gui/window/win_search.py +++ b/tryton/gui/window/win_search.py @@ -23,6 +23,8 @@ class WinSearch(NoModal): views_preload = {} self.domain = domain or [] self.context = context or {} + self.view_ids = view_ids + self.views_preload = views_preload self.sel_multi = sel_multi self.callback = callback self.title = title @@ -112,8 +114,11 @@ class WinSearch(NoModal): self.screen.search_filter(self.screen.screen_container.get_text()) return elif response_id == gtk.RESPONSE_ACCEPT: + # Remove first tree view as mode if form only + view_ids = self.view_ids[1:] screen = Screen(self.model_name, domain=self.domain, - context=self.context, mode=['form']) + context=self.context, mode=['form'], + view_ids=view_ids, views_preload=self.views_preload) def callback(result): if result: