From 2fb17eebec71b367042572b796993fd511586b07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 19 Feb 2020 22:54:21 +0100 Subject: [PATCH] Always use search_context for creation from Many2One and remove unused context from Many2Many WinForm as it is only for tree view. issue9023 review282871003 --- tryton/gui/window/view_form/view/form_gtk/many2one.py | 9 ++++++--- tryton/gui/window/view_form/view/form_gtk/one2many.py | 4 +--- 2 files changed, 7 insertions(+), 6 deletions(-) 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 27a41c52a0..ee98d28d7f 100644 --- a/tryton/gui/window/view_form/view/form_gtk/many2one.py +++ b/tryton/gui/window/view_form/view/form_gtk/many2one.py @@ -144,9 +144,12 @@ class Many2One(Widget): self.changed = True return - def get_screen(self): + def get_screen(self, search=False): domain = self.field.domain_get(self.record) - context = self.field.get_context(self.record) + if search: + context = self.field.get_search_context(self.record) + else: + 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, @@ -159,7 +162,7 @@ class Many2One(Widget): if not model or not common.MODELACCESS[model]['create']: return self.focus_out = False - screen = self.get_screen() + screen = self.get_screen(search=True) def callback(result): if result: diff --git a/tryton/gui/window/view_form/view/form_gtk/one2many.py b/tryton/gui/window/view_form/view/form_gtk/one2many.py index 22ede0d34a..fb392dc125 100644 --- a/tryton/gui/window/view_form/view/form_gtk/one2many.py +++ b/tryton/gui/window/view_form/view/form_gtk/one2many.py @@ -337,8 +337,6 @@ class One2Many(Widget): self._new_single() def _new_single(self): - ctx = {} - ctx.update(self.field.get_context(self.record)) sequence = self._sequence() def update_sequence(): @@ -353,7 +351,7 @@ class One2Many(Widget): field_size = self.record.expr_eval(self.attrs.get('size')) or -1 field_size -= len(self.field.get_eval(self.record)) + 1 WinForm(self.screen, lambda a: update_sequence(), new=True, - many=field_size, context=ctx, title=self.attrs.get('string')) + many=field_size, title=self.attrs.get('string')) def _new_product(self): fields = self.attrs['product'].split(',')