From 0fa3ffd591eccc6a83e8f399003bff8a60c15922 Mon Sep 17 00:00:00 2001
From: Ayush <ayush.tiwari@nexedi.com>
Date: Thu, 24 Aug 2017 15:32:39 +0200
Subject: [PATCH] BusinessTemplate: Maintain consisitency while adding values
 in modified_object_list

In al the TemplateItem objects, we consider the values being added to modified_object_list
in the format {<object_path>: [List of changed action]}. But, for ObjectTemplateItem we
used to add tuples instead of list. This was not getting tested as we always had cases
where we had old_xml and new_xml similar to each other.
This also explains why some tests were expecting tuples and not lists in this commit:
https://lab.nexedi.com/nexedi/erp5/commit/727477a32b1b5dafb14e01c28d07dd029fb4fac8

But, fortunately this came to notice after migrating SQL Method objects to behave as
ERP5fied objects.
---
 product/ERP5/Document/BusinessTemplate.py              | 10 +++++-----
 product/ERP5/tests/testBusinessTemplate.py             |  4 ++--
 .../ERP5/tests/testBusinessTemplateTwoFileExport.py    |  2 +-
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/product/ERP5/Document/BusinessTemplate.py b/product/ERP5/Document/BusinessTemplate.py
index 032100f22f..8f6aae92ea 100644
--- a/product/ERP5/Document/BusinessTemplate.py
+++ b/product/ERP5/Document/BusinessTemplate.py
@@ -1073,7 +1073,7 @@ class ObjectTemplateItem(BaseTemplateItem):
       if installed_item._objects.has_key(path):
         upgrade_list.append((path, installed_item._objects[path]))
       else: # new object
-        modified_object_list[path] = 'New', type_name
+        modified_object_list[path] = ['New', type_name]
 
     # update _p_jar property of objects cleaned by removeProperties
     transaction.savepoint(optimistic=True)
@@ -1094,15 +1094,15 @@ class ObjectTemplateItem(BaseTemplateItem):
       old_io.close()
       if new_obj_xml != old_obj_xml:
         if context.isKeepObject(path):
-          modified_object_list[path] = 'Modified but should be kept', type_name
+          modified_object_list[path] = ['Modified but should be kept', type_name]
         else:
-          modified_object_list[path] = 'Modified', type_name
+          modified_object_list[path] = ['Modified', type_name]
     # get removed object
     for path in set(installed_item._objects) - set(self._objects):
       if context.isKeepObject(path):
-        modified_object_list[path] = 'Removed but should be kept', type_name
+        modified_object_list[path] = ['Removed but should be kept', type_name]
       else:
-        modified_object_list[path] = 'Removed', type_name
+        modified_object_list[path] = ['Removed', type_name]
     return modified_object_list
 
   def _backupObject(self, action, trashbin, container_path, object_id, **kw):
diff --git a/product/ERP5/tests/testBusinessTemplate.py b/product/ERP5/tests/testBusinessTemplate.py
index f82a261bf7..9ce19d0941 100644
--- a/product/ERP5/tests/testBusinessTemplate.py
+++ b/product/ERP5/tests/testBusinessTemplate.py
@@ -6857,7 +6857,7 @@ class TestBusinessTemplate(BusinessTemplateMixin):
     finally:
       shutil.rmtree(export_dir)
     self.assertEqual(
-       {'test_document': ('Removed but should be kept', 'Path')},
+       {'test_document': ['Removed but should be kept', 'Path']},
        new_bt.preinstall())
 
   def test_update_business_template_with_template_keep_path_list_catalog_method(self):
@@ -6912,7 +6912,7 @@ class TestBusinessTemplate(BusinessTemplateMixin):
       shutil.rmtree(export_dir)
     self.assertEqual(
        {'portal_catalog/erp5_mysql_innodb/z_fake_method':
-         ('Removed but should be kept', 'CatalogMethod')},
+         ['Removed but should be kept', 'CatalogMethod']},
        new_bt.preinstall())
 
   def test_BusinessTemplateWithTest(self):
diff --git a/product/ERP5/tests/testBusinessTemplateTwoFileExport.py b/product/ERP5/tests/testBusinessTemplateTwoFileExport.py
index b02782ad04..b2e170eaf6 100644
--- a/product/ERP5/tests/testBusinessTemplateTwoFileExport.py
+++ b/product/ERP5/tests/testBusinessTemplateTwoFileExport.py
@@ -1155,4 +1155,4 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
     # the PythonScript is recognised as modified
     result = second_import_template.preinstall()
     self.assertEquals(result.get('portal_skins/%s/%s' % (skin_folder_id, python_script_id)),
-                      ('Modified', 'Skin'))
+                      ['Modified', 'Skin'])
-- 
2.30.9