From 3c17164458aa0e334888953ed22d2f25c639df37 Mon Sep 17 00:00:00 2001
From: Vincent Pelletier <vincent@nexedi.com>
Date: Tue, 12 Nov 2019 16:46:08 +0900
Subject: [PATCH] ERP5Form.Listbox: Do not use column titles from selection.

These titles duplicate listbox configuration, preventing any change from
reaching users (...who customised their listbox).
Also fixes cases where column title was stored in selection after
translation, which breaks some reports.
---
 product/ERP5Form/ListBox.py | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/product/ERP5Form/ListBox.py b/product/ERP5Form/ListBox.py
index 9e414d6d1e..913d8eb50a 100644
--- a/product/ERP5Form/ListBox.py
+++ b/product/ERP5Form/ListBox.py
@@ -1096,9 +1096,9 @@ class ListBoxRenderer:
     """
     listbox_display_style = self.getListboxDisplayStyle()
     displayed_column_id_list = self.getDisplayedColumnIdList()
+    available_column_dict = {x[0]: x for x in self.getAllColumnList()}
     if displayed_column_id_list is not None:
       # dynamically setting columns is supported
-      available_column_dict = {x[0]: x for x in self.getAllColumnList()}
       column_list = []
       for id in displayed_column_id_list:
         try:
@@ -1115,11 +1115,14 @@ class ListBoxRenderer:
         for x in self.getStyleColumnList()
         if x[1].startswith(list_style_prefix)
       ]
-    return self.getSelectionTool().getSelectionColumns(
-      self.getSelectionName(),
-      columns=self.getColumnList(),
-      REQUEST=self.request,
-    )
+    return [
+      (x[0], available_column_dict.get(x[0], x)[1])
+      for x in self.getSelectionTool().getSelectionColumns(
+        self.getSelectionName(),
+        columns=self.getColumnList(),
+        REQUEST=self.request,
+      )
+    ]
 
   @lazyMethod
   def getColumnAliasList(self):
-- 
2.30.9