From 030305ec49226e751ae86665a06de63e2f0e7b99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 18 Dec 2024 17:54:06 +0100 Subject: [PATCH] Set screen to ScreenContainer at instantiation Many methods of ScreenContainer relies on the screen being set. And there is no reason to not set the screen at instantiation as long as show filter refresh the bookmarks. Closes #13757 --- sao/src/screen.js | 15 ++++++--------- .../tryton/gui/window/view_form/screen/screen.py | 4 ++-- .../gui/window/view_form/view/screen_container.py | 8 +++----- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/sao/src/screen.js b/sao/src/screen.js index ff4761cbef..8e731978e0 100644 --- a/sao/src/screen.js +++ b/sao/src/screen.js @@ -4,7 +4,8 @@ 'use strict'; Sao.ScreenContainer = Sao.class_(Object, { - init: function(tab_domain) { + init: function(screen, tab_domain) { + this.screen = screen; this.alternate_viewport = jQuery('
', { 'class': 'screen-container' }); @@ -389,13 +390,10 @@ do_search: function() { return this.screen.search_filter(this.get_text()); }, - set_screen: function(screen) { - this.screen = screen; - this.but_bookmark.prop('disabled', - jQuery.isEmptyObject(this.bookmarks())); - this.bookmark_match(); - }, show_filter: function() { + this.but_bookmark.prop( + 'disabled', jQuery.isEmptyObject(this.bookmarks())); + this.bookmark_match(); this.filter_box.show(); if (this.tab) { this.tab.show(); @@ -815,7 +813,7 @@ this.new_group(attributes.context || {}); this.current_record = null; this.screen_container = new Sao.ScreenContainer( - attributes.tab_domain); + this, attributes.tab_domain); this.breadcrumb = attributes.breadcrumb || []; this.context_screen = null; @@ -1750,7 +1748,6 @@ }, search_active: function(active) { if (active && !this.group.parent) { - this.screen_container.set_screen(this); this.screen_container.show_filter(); } else { this.screen_container.hide_filter(); diff --git a/tryton/tryton/gui/window/view_form/screen/screen.py b/tryton/tryton/gui/window/view_form/screen/screen.py index ec78e938cc..a397639a9f 100644 --- a/tryton/tryton/gui/window/view_form/screen/screen.py +++ b/tryton/tryton/gui/window/view_form/screen/screen.py @@ -75,7 +75,8 @@ class Screen: self.__current_record = None self.new_group(context or {}) self.current_record = None - self.screen_container = ScreenContainer(attributes.get('tab_domain')) + self.screen_container = ScreenContainer( + self, attributes.get('tab_domain')) self.screen_container.alternate_view = attributes.get( 'alternate_view', False) self.widget = self.screen_container.widget_get() @@ -163,7 +164,6 @@ class Screen: def search_active(self, active=True): if active and not self.parent: - self.screen_container.set_screen(self) self.screen_container.show_filter() else: self.screen_container.hide_filter() diff --git a/tryton/tryton/gui/window/view_form/view/screen_container.py b/tryton/tryton/gui/window/view_form/view/screen_container.py index a92a644e5b..e09c7fb3f0 100644 --- a/tryton/tryton/gui/window/view_form/view/screen_container.py +++ b/tryton/tryton/gui/window/view_form/view/screen_container.py @@ -185,7 +185,8 @@ class Selection(Gtk.ScrolledWindow): class ScreenContainer(object): - def __init__(self, tab_domain): + def __init__(self, screen, tab_domain): + self.screen = screen self.viewport = Gtk.Viewport() self.viewport.set_shadow_type(Gtk.ShadowType.NONE) self.vbox = Gtk.VBox(spacing=3) @@ -351,12 +352,9 @@ class ScreenContainer(object): def widget_get(self): return self.vbox - def set_screen(self, screen): - self.screen = screen + def show_filter(self): self.but_bookmark.set_sensitive(bool(list(self.bookmarks()))) self.bookmark_match() - - def show_filter(self): if self.filter_vbox: self.filter_vbox.show() if self.notebook: