From d771ed9402e20151c0e1673a7bbb86f489fb9013 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 26 Mar 2024 11:20:07 +0100 Subject: [PATCH] Do not set current record to the first id if the list is empty Closes #13130 (grafted from 61da30b168e7a11392ac235bea43460bbb998873) --HG-- branch : 7.0 --- sao/src/tab.js | 6 ++++-- tryton/tryton/gui/window/form.py | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/sao/src/tab.js b/sao/src/tab.js index 8878f84eb5..11feb64320 100644 --- a/sao/src/tab.js +++ b/sao/src/tab.js @@ -506,8 +506,10 @@ attributes.res_id = [attributes.res_id]; } screen.load(attributes.res_id); - screen.current_record = screen.group.get( - attributes.res_id[0]); + if (attributes.res_id.length) { + screen.current_record = screen.group.get( + attributes.res_id[0]); + } screen.display(); } else { if (screen.current_view.view_type == 'form') { diff --git a/tryton/tryton/gui/window/form.py b/tryton/tryton/gui/window/form.py index cd62fbaa4c..7a81dc87a0 100644 --- a/tryton/tryton/gui/window/form.py +++ b/tryton/tryton/gui/window/form.py @@ -66,7 +66,8 @@ class Form(TabContent): if isinstance(res_id, int): res_id = [res_id] self.screen.load(res_id) - self.screen.current_record = self.screen.group.get(res_id[0]) + if res_id: + self.screen.current_record = self.screen.group.get(res_id[0]) self.screen.display() else: if self.screen.current_view.view_type == 'form':