From d62f2acb087a3bd3aa6481bd54b71fd46b90c890 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sat, 21 Jan 2023 19:37:19 +0100 Subject: [PATCH] Instantiate always Screen for xxx2Many fields with the same parameters The screen must be instantiated with the context of the parent screen so eventual field_view_get would give the same result. The limit must always be set to None/null to ensure to load all the records. The breadcrumb must be set to show navigation to the user. Closes #3140 --- sao/src/view/form.js | 10 ++++++++-- .../gui/window/view_form/view/form_gtk/many2many.py | 10 ++++++++-- .../gui/window/view_form/view/form_gtk/one2many.py | 1 + .../gui/window/view_form/view/list_gtk/widget.py | 4 ++++ 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/sao/src/view/form.js b/sao/src/view/form.js index e22688efc3..d6e3cfa2d5 100644 --- a/sao/src/view/form.js +++ b/sao/src/view/form.js @@ -3231,6 +3231,7 @@ function eval_pyson(value){ row_activate: this.activate.bind(this), exclude_field: attributes.relation_field || null, limit: null, + context: this.view.screen.context, pre_validate: attributes.pre_validate, breadcrumb: breadcrumb, }); @@ -3812,6 +3813,7 @@ function eval_pyson(value){ row_activate: this.activate.bind(this), readonly: true, limit: null, + context: this.view.screen.context, breadcrumb: breadcrumb, }); this.screen.windows.push(this); @@ -3986,12 +3988,16 @@ function eval_pyson(value){ // Remove the first tree view as mode is form only view_ids.shift(); } - return new Sao.Screen(this.attributes.relation, { + var model = this.attributes.relation; + var breadcrumb = jQuery.extend([], this.view.screen.breadcrumb); + breadcrumb.push(this.attributes.string || Sao.common.MODELNAME.get(model)); + return new Sao.Screen(model, { 'domain': domain, 'view_ids': view_ids, 'mode': ['form'], 'views_preload': this.attributes.views, - 'context': context + 'context': context, + 'breadcrumb': breadcrumb, }); }, edit: function() { diff --git a/tryton/tryton/gui/window/view_form/view/form_gtk/many2many.py b/tryton/tryton/gui/window/view_form/view/form_gtk/many2many.py index c8e98d776d..785da649e8 100644 --- a/tryton/tryton/gui/window/view_form/view/form_gtk/many2many.py +++ b/tryton/tryton/gui/window/view_form/view/form_gtk/many2many.py @@ -90,13 +90,19 @@ class Many2Many(Widget): frame.set_shadow_type(Gtk.ShadowType.OUT) vbox.pack_start(frame, expand=False, fill=True, padding=0) - self.screen = Screen(attrs['relation'], + model = attrs['relation'] + breadcrumb = list(self.view.screen.breadcrumb) + breadcrumb.append( + attrs.get('string') or common.MODELNAME.get(model)) + self.screen = Screen(model, view_ids=attrs.get('view_ids', '').split(','), mode=['tree'], views_preload=attrs.get('views', {}), order=attrs.get('order'), row_activate=self._on_activate, readonly=True, - limit=None) + limit=None, + context=self.view.screen.context, + breadcrumb=breadcrumb) self.screen.windows.append(self) vbox.pack_start(self.screen.widget, expand=True, fill=True, padding=0) diff --git a/tryton/tryton/gui/window/view_form/view/form_gtk/one2many.py b/tryton/tryton/gui/window/view_form/view/form_gtk/one2many.py index 67e58e2390..22ade944ff 100644 --- a/tryton/tryton/gui/window/view_form/view/form_gtk/one2many.py +++ b/tryton/tryton/gui/window/view_form/view/form_gtk/one2many.py @@ -168,6 +168,7 @@ class One2Many(Widget): row_activate=self._on_activate, exclude_field=attrs.get('relation_field', None), limit=None, + context=self.view.screen.context, breadcrumb=breadcrumb) self.screen.pre_validate = bool(int(attrs.get('pre_validate', 0))) self.screen.windows.append(self) diff --git a/tryton/tryton/gui/window/view_form/view/list_gtk/widget.py b/tryton/tryton/gui/window/view_form/view/list_gtk/widget.py index ae46c16252..e3b2d48c7d 100644 --- a/tryton/tryton/gui/window/view_form/view/list_gtk/widget.py +++ b/tryton/tryton/gui/window/view_form/view/list_gtk/widget.py @@ -998,6 +998,8 @@ class O2M(GenericText): screen = Screen(relation, mode=['tree', 'form'], view_ids=self.attrs.get('view_ids', '').split(','), exclude_field=field.attrs.get('relation_field'), + limit=None, + context=self.view.screen.context, breadcrumb=breadcrumb) screen.pre_validate = bool(int(self.attrs.get('pre_validate', 0))) screen.group = group @@ -1024,6 +1026,8 @@ class M2M(O2M): screen = Screen(relation, mode=['tree', 'form'], view_ids=self.attrs.get('view_ids', '').split(','), exclude_field=field.attrs.get('relation_field'), + limit=None, + context=self.view.screen.context, breadcrumb=breadcrumb) screen.group = group