From af6b1412bc2556f8816cdb6f252cdc8d363ff3dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 10 Apr 2017 23:20:58 +0200 Subject: [PATCH] Remove only initially selected rows in CSV export/import The selection is changed after each removal and select new rows which result in removing all the rows. Indeed the TreeIter should be computed before modifying the store to ensure to always remove the right rows. issue6413 review37311002 --- tryton/gui/window/win_export.py | 7 ++++--- tryton/gui/window/win_import.py | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/tryton/gui/window/win_export.py b/tryton/gui/window/win_export.py index d9ffdd7ecf..1f17075825 100644 --- a/tryton/gui/window/win_export.py +++ b/tryton/gui/window/win_export.py @@ -148,9 +148,10 @@ class WinExport(WinCSV): def sig_unsel(self, *args): store, paths = self.view2.get_selection().get_selected_rows() - while paths: - store.remove(store.get_iter(paths[0])) - store, paths = self.view2.get_selection().get_selected_rows() + # Convert first into TreeIter before removing from the store + iters = [store.get_iter(p) for p in paths] + for i in iters: + store.remove(i) def sig_unsel_all(self, *args): self.model2.clear() diff --git a/tryton/gui/window/win_import.py b/tryton/gui/window/win_import.py index 4890078c30..2f99d75eea 100644 --- a/tryton/gui/window/win_import.py +++ b/tryton/gui/window/win_import.py @@ -157,9 +157,10 @@ class WinImport(WinCSV): def sig_unsel(self, *args): store, paths = self.view2.get_selection().get_selected_rows() - while paths: - store.remove(store.get_iter(paths[0])) - store, paths = self.view2.get_selection().get_selected_rows() + # Convert first into TreeIter before removing from the store + iters = [store.get_iter(p) for p in paths] + for i in iters: + store.remove(i) def sig_unsel_all(self, *args): self.model2.clear()