details: https://code.tryton.org/tryton/commit/1147502ee8dd
branch: default
user: Nicolas Évrard <[email protected]>
date: Wed Jul 29 17:48:54 2026 +0200
description:
Explicitly set the previous view to switch to when opening a new Form
Closes #14975
diffstat:
sao/src/view/form.js | 2 +
sao/src/window.js | 7 ++++-
tryton/tryton/gui/window/attachment.py | 5 ++-
tryton/tryton/gui/window/log.py | 4 ++-
tryton/tryton/gui/window/note.py | 5 ++-
tryton/tryton/gui/window/view_board/action.py | 4 ++-
tryton/tryton/gui/window/view_form/view/form_gtk/many2many.py | 6 ++-
tryton/tryton/gui/window/view_form/view/form_gtk/many2one.py | 5 ++-
tryton/tryton/gui/window/view_form/view/form_gtk/one2many.py | 5 ++-
tryton/tryton/gui/window/view_form/view/list_gtk/widget.py | 15 +++++++---
tryton/tryton/gui/window/win_form.py | 11 +++++--
tryton/tryton/gui/window/win_search.py | 4 ++-
12 files changed, 51 insertions(+), 22 deletions(-)
diffs (261 lines):
diff -r f56a0a6d5558 -r 1147502ee8dd sao/src/view/form.js
--- a/sao/src/view/form.js Thu Sep 10 08:20:15 2026 +0200
+++ b/sao/src/view/form.js Wed Jul 29 17:48:54 2026 +0200
@@ -2928,6 +2928,7 @@
screen.current_record = screen.group.get(m2o_id);
new Sao.Window.Form(screen, callback, {
save_current: true,
+ prev_view: null,
});
});
return;
@@ -2998,6 +2999,7 @@
new_: true,
save_current: true,
defaults: defaults,
+ prev_view: null,
});
});
},
diff -r f56a0a6d5558 -r 1147502ee8dd sao/src/window.js
--- a/sao/src/window.js Thu Sep 10 08:20:15 2026 +0200
+++ b/sao/src/window.js Wed Jul 29 17:48:54 2026 +0200
@@ -162,7 +162,12 @@
return label;
});
- this.prev_view = screen.current_view;
+ // prev_view should stay null
+ if (kwargs.prev_view !== undefined) {
+ this.prev_view = kwargs.prev_view;
+ } else {
+ this.prev_view = screen.current_view;
+ }
this.screen.screen_container.alternate_view = true;
this.info_bar = new Sao.Window.InfoBar();
var view_type = kwargs.view_type || 'form';
diff -r f56a0a6d5558 -r 1147502ee8dd tryton/tryton/gui/window/attachment.py
--- a/tryton/tryton/gui/window/attachment.py Thu Sep 10 08:20:15 2026 +0200
+++ b/tryton/tryton/gui/window/attachment.py Wed Jul 29 17:48:54 2026 +0200
@@ -28,8 +28,9 @@
],
mode=['tree', 'form'],
readonly=not access['write'])
- super().__init__(screen, self.callback,
- view_type='tree', title=title)
+ super().__init__(
+ screen, self.callback, view_type='tree', title=title,
+ prev_view=screen.current_view)
screen.search_filter()
def destroy(self):
diff -r f56a0a6d5558 -r 1147502ee8dd tryton/tryton/gui/window/log.py
--- a/tryton/tryton/gui/window/log.py Thu Sep 10 08:20:15 2026 +0200
+++ b/tryton/tryton/gui/window/log.py Wed Jul 29 17:48:54 2026 +0200
@@ -110,7 +110,9 @@
screen = Screen('ir.model.log', domain=[
('resource', '=', self.resource),
], mode=['tree', 'form'])
- super().__init__(screen, view_type='tree', title=title)
+ super().__init__(
+ screen, view_type='tree', title=title,
+ prev_view=screen.current_view)
screen.search_filter()
self.win.vbox.pack_start(grid, expand=False, fill=True, padding=0)
diff -r f56a0a6d5558 -r 1147502ee8dd tryton/tryton/gui/window/note.py
--- a/tryton/tryton/gui/window/note.py Thu Sep 10 08:20:15 2026 +0200
+++ b/tryton/tryton/gui/window/note.py Wed Jul 29 17:48:54 2026 +0200
@@ -18,8 +18,9 @@
screen = Screen('ir.note', domain=[
('resource', '=', self.resource),
], mode=['tree', 'form'])
- super().__init__(screen, self.callback, view_type='tree',
- title=title)
+ super().__init__(
+ screen, self.callback, view_type='tree', title=title,
+ prev_view=screen.current_view)
screen.search_filter()
def destroy(self):
diff -r f56a0a6d5558 -r 1147502ee8dd
tryton/tryton/gui/window/view_board/action.py
--- a/tryton/tryton/gui/window/view_board/action.py Thu Sep 10 08:20:15
2026 +0200
+++ b/tryton/tryton/gui/window/view_board/action.py Wed Jul 29 17:48:54
2026 +0200
@@ -120,7 +120,9 @@
self.screen.current_record.save()
else:
self.screen.current_record.cancel()
- WinForm(self.screen, callback, title=self.title.get_text())
+ WinForm(
+ self.screen, callback, title=self.title.get_text(),
+ prev_view=self.screen.current_view)
def display(self):
self.screen.search_filter(self.screen.screen_container.get_text())
diff -r f56a0a6d5558 -r 1147502ee8dd
tryton/tryton/gui/window/view_form/view/form_gtk/many2many.py
--- a/tryton/tryton/gui/window/view_form/view/form_gtk/many2many.py Thu Sep
10 08:20:15 2026 +0200
+++ b/tryton/tryton/gui/window/view_form/view/form_gtk/many2many.py Wed Jul
29 17:48:54 2026 +0200
@@ -284,7 +284,8 @@
# Force a display to clear the CellCache
self.screen.display()
self._popup = False
- WinForm(screen, callback, save_current=True)
+ WinForm(
+ screen, callback, save_current=True, prev_view=screen.current_view)
def _sig_new(self, defaults=None):
if self._popup:
@@ -304,7 +305,8 @@
self._popup = False
WinForm(
- screen, callback, new=True, save_current=True, defaults=defaults)
+ screen, callback, new=True, save_current=True, defaults=defaults,
+ prev_view=screen.current_view)
def _readonly_set(self, value):
super()._readonly_set(value)
diff -r f56a0a6d5558 -r 1147502ee8dd
tryton/tryton/gui/window/view_form/view/form_gtk/many2one.py
--- a/tryton/tryton/gui/window/view_form/view/form_gtk/many2one.py Thu Sep
10 08:20:15 2026 +0200
+++ b/tryton/tryton/gui/window/view_form/view/form_gtk/many2one.py Wed Jul
29 17:48:54 2026 +0200
@@ -186,7 +186,8 @@
screen.current_record.rec_name()))
self._popup = False
WinForm(
- screen, callback, new=True, save_current=True, defaults=defaults)
+ screen, callback, new=True, save_current=True, defaults=defaults,
+ prev_view=None)
def sig_edit(self, entry=None, icon_pos=None, *args):
if entry:
@@ -225,7 +226,7 @@
force_change=True)
self._popup = False
self.changed = True
- WinForm(screen, callback, save_current=True)
+ WinForm(screen, callback, save_current=True, prev_view=None)
return
if not self._readonly:
domain = self.field.domain_get(self.record)
diff -r f56a0a6d5558 -r 1147502ee8dd
tryton/tryton/gui/window/view_form/view/form_gtk/one2many.py
--- a/tryton/tryton/gui/window/view_form/view/form_gtk/one2many.py Thu Sep
10 08:20:15 2026 +0200
+++ b/tryton/tryton/gui/window/view_form/view/form_gtk/one2many.py Wed Jul
29 17:48:54 2026 +0200
@@ -398,7 +398,8 @@
field_size -= len(self.field.get_eval(self.record)) + 1
WinForm(
self.screen, lambda a: update_sequence(), new=True,
- defaults=defaults, many=field_size)
+ defaults=defaults, many=field_size,
+ prev_view=self.screen.current_view)
def _new_product(self, defaults=None):
fields = self.attrs['product'].split(',')
@@ -472,7 +473,7 @@
def callback(result):
self._popup = False
- WinForm(self.screen, callback)
+ WinForm(self.screen, callback, prev_view=self.screen.current_view)
def _sig_next(self, widget):
if not self._validate():
diff -r f56a0a6d5558 -r 1147502ee8dd
tryton/tryton/gui/window/view_form/view/list_gtk/widget.py
--- a/tryton/tryton/gui/window/view_form/view/list_gtk/widget.py Thu Sep
10 08:20:15 2026 +0200
+++ b/tryton/tryton/gui/window/view_form/view/list_gtk/widget.py Wed Jul
29 17:48:54 2026 +0200
@@ -974,13 +974,15 @@
if target_id and target_id >= 0:
screen.load([target_id])
screen.current_record = screen.group.get(target_id)
- WinForm(screen, open_callback, save_current=True)
+ WinForm(
+ screen, open_callback, save_current=True,
+ prev_view=screen.current_view)
else:
defaults = defaults.copy() if defaults is not None else {}
defaults['rec_name'] = text
WinForm(
screen, open_callback, new=True, save_current=True,
- defaults=defaults)
+ defaults=defaults, prev_view=screen.current_view)
def search_remote(self, record, field, text, callback=None):
model = self.get_model(record, field)
@@ -1127,7 +1129,9 @@
def open_callback(result):
if callback:
callback()
- WinForm(screen, open_callback, view_type='tree', context=context)
+ WinForm(
+ screen, open_callback, view_type='tree', context=context,
+ prev_view=screen.current_view)
class M2M(O2M):
@@ -1154,8 +1158,9 @@
def open_callback(result):
if callback:
callback()
- WinForm(screen, open_callback, view_type='tree', domain=domain,
- context=context)
+ WinForm(
+ screen, open_callback, view_type='tree', domain=domain,
+ context=context, prev_view=screen.current_view)
class Selection(GenericText, SelectionMixin, PopdownMixin):
diff -r f56a0a6d5558 -r 1147502ee8dd tryton/tryton/gui/window/win_form.py
--- a/tryton/tryton/gui/window/win_form.py Thu Sep 10 08:20:15 2026 +0200
+++ b/tryton/tryton/gui/window/win_form.py Wed Jul 29 17:48:54 2026 +0200
@@ -16,6 +16,7 @@
from .infobar import InfoBar
_ = gettext.gettext
+SENTINEL = object()
class WinForm(NoModal, InfoBar):
@@ -23,7 +24,7 @@
def __init__(self, screen, callback=None, view_type='form',
new=False, many=0, domain=None, context=None,
- save_current=False, title='', defaults=None):
+ save_current=False, title='', defaults=None, prev_view=SENTINEL):
tooltips = common.Tooltips()
NoModal.__init__(self)
@@ -49,7 +50,10 @@
if not title:
title = MODELNAME.get(screen.model_name)
self.title = title
- self.prev_view = self.screen.current_view
+ if prev_view is not SENTINEL:
+ self.prev_view = prev_view
+ else:
+ self.prev_view = screen.current_view
self.screen.screen_container.alternate_view = True
self.screen.switch_view(view_type=view_type)
if self.screen.current_view.view_type != view_type:
@@ -519,7 +523,8 @@
viewport = self.screen.screen_container.alternate_viewport
if viewport and viewport.get_parent():
viewport.get_parent().remove(viewport)
- self.screen.switch_view(view_type=self.prev_view.view_type)
+ if self.prev_view:
+ self.screen.switch_view(view_type=self.prev_view.view_type)
if getattr(self, 'win', None):
self.win.destroy()
NoModal.destroy(self)
diff -r f56a0a6d5558 -r 1147502ee8dd tryton/tryton/gui/window/win_search.py
--- a/tryton/tryton/gui/window/win_search.py Thu Sep 10 08:20:15 2026 +0200
+++ b/tryton/tryton/gui/window/win_search.py Wed Jul 29 17:48:54 2026 +0200
@@ -167,7 +167,9 @@
else:
self.callback(None)
self.destroy()
- WinForm(screen, callback, new=True, save_current=True)
+ WinForm(
+ screen, callback, new=True, save_current=True,
+ prev_view=screen.current_view)
return
if res:
group = self.screen.group