From 46c584787d2ec02d94c9dd4a5e67bd596a6ccf86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 25 May 2016 11:13:23 +0200 Subject: [PATCH] Remove Screen.parent hack in Attachment and Note The modified test in Screen.switch_view can be moved to Screen.default_row_activate only, so the Attachment and Note screen doesn't require to have a fake parent to switch views. issue5558 review20201002 --- tryton/gui/window/attachment.py | 2 -- tryton/gui/window/note.py | 2 -- tryton/gui/window/view_form/screen/screen.py | 5 ++--- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/tryton/gui/window/attachment.py b/tryton/gui/window/attachment.py index da0e1464f0..0095870a4a 100644 --- a/tryton/gui/window/attachment.py +++ b/tryton/gui/window/attachment.py @@ -25,8 +25,6 @@ class Attachment(WinForm): super(Attachment, self).__init__(screen, self.callback, view_type='tree') screen.search_filter() - # Set parent after to be allowed to call search_filter - screen.parent = record def destroy(self): self.prev_view.save_width_height() diff --git a/tryton/gui/window/note.py b/tryton/gui/window/note.py index 0c09082602..efac25b21b 100644 --- a/tryton/gui/window/note.py +++ b/tryton/gui/window/note.py @@ -19,8 +19,6 @@ class Note(WinForm): exclude_field='resource') super(Note, self).__init__(screen, self.callback, view_type='tree') screen.search_filter() - # Set parent after to be allowed to call search_filter - screen.parent = record def destroy(self): self.prev_view.save_width_height() diff --git a/tryton/gui/window/view_form/screen/screen.py b/tryton/gui/window/view_form/screen/screen.py index 2dcada0e14..c79c2deb6b 100644 --- a/tryton/gui/window/view_form/screen/screen.py +++ b/tryton/gui/window/view_form/screen/screen.py @@ -427,7 +427,8 @@ class Screen(SignalEvent): 'ids': [r.id for r in self.selected_records], }, context=self.context.copy(), warning=False) else: - self.switch_view(view_type='form') + if not self.modified(): + self.switch_view(view_type='form') return True @property @@ -436,8 +437,6 @@ class Screen(SignalEvent): def switch_view(self, view_type=None): if self.current_view: - if not self.parent and self.modified(): - return self.current_view.set_value() if (self.current_record and self.current_record not in self.current_record.group):