From 72425445062bc595d0718d83580de9901023aaf3 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Thu, 12 Apr 2018 13:32:17 +0200 Subject: [PATCH] [FIX] base_import: activate advanced mode The commit 1ba4fbe640cf22abe did not match the specs of the task, but was merged anyway. Reverting the commit, and check by default so the user is not confused with missing fields. opw-1824074 --- addons/base_import/models/base_import.py | 1 - addons/base_import/static/src/js/import_action.js | 1 - addons/base_import/static/src/xml/base_import.xml | 2 +- addons/base_import/tests/test_base_import.py | 8 ++++---- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/addons/base_import/models/base_import.py b/addons/base_import/models/base_import.py index dbff99fab88..748b37e86af 100644 --- a/addons/base_import/models/base_import.py +++ b/addons/base_import/models/base_import.py @@ -497,7 +497,6 @@ class Import(models.TransientModel): 'headers_type': header_types or False, 'preview': preview, 'options': options, - 'advanced_mode': any([len(models.fix_import_export_id_paths(col)) > 1 for col in headers or []]), 'debug': self.user_has_groups('base.group_no_one'), } except Exception as error: diff --git a/addons/base_import/static/src/js/import_action.js b/addons/base_import/static/src/js/import_action.js index 1872dec6205..153e41ed632 100644 --- a/addons/base_import/static/src/js/import_action.js +++ b/addons/base_import/static/src/js/import_action.js @@ -301,7 +301,6 @@ var DataImport = Widget.extend(ControlPanelMixin, { this.$buttons.filter('.o_import_button').add(this.$('.oe_import_file_reload')) .prop('disabled', false); this.$el.addClass('oe_import_preview'); - this.$('input.oe_import_advanced_mode').prop('checked', result.advanced_mode); this.$('.oe_import_grid').html(QWeb.render('ImportView.preview', result)); if (result.headers.length === 1) { diff --git a/addons/base_import/static/src/xml/base_import.xml b/addons/base_import/static/src/xml/base_import.xml index c9c4e8a5037..7a9881849ac 100644 --- a/addons/base_import/static/src/xml/base_import.xml +++ b/addons/base_import/static/src/xml/base_import.xml @@ -76,7 +76,7 @@ id="oe_import_has_header" checked="checked"/> -

If the file contains diff --git a/addons/base_import/tests/test_base_import.py b/addons/base_import/tests/test_base_import.py index 55f3300da91..df2d18a3feb 100644 --- a/addons/base_import/tests/test_base_import.py +++ b/addons/base_import/tests/test_base_import.py @@ -258,7 +258,7 @@ class TestPreview(TransactionCase): ['qux', '5', '6'], ]) # Ensure we only have the response fields we expect - self.assertItemsEqual(list(result), ['matches', 'headers', 'fields', 'preview', 'headers_type', 'options', 'advanced_mode', 'debug']) + self.assertItemsEqual(list(result), ['matches', 'headers', 'fields', 'preview', 'headers_type', 'options', 'debug']) @unittest.skipUnless(can_import('xlrd'), "XLRD module not available") def test_xls_success(self): @@ -288,7 +288,7 @@ class TestPreview(TransactionCase): ['qux', '5', '6'], ]) # Ensure we only have the response fields we expect - self.assertItemsEqual(list(result), ['matches', 'headers', 'fields', 'preview', 'headers_type', 'options', 'advanced_mode', 'debug']) + self.assertItemsEqual(list(result), ['matches', 'headers', 'fields', 'preview', 'headers_type', 'options', 'debug']) @unittest.skipUnless(can_import('xlrd.xlsx'), "XLRD/XLSX not available") def test_xlsx_success(self): @@ -318,7 +318,7 @@ class TestPreview(TransactionCase): ['qux', '5', '6'], ]) # Ensure we only have the response fields we expect - self.assertItemsEqual(list(result), ['matches', 'headers', 'fields', 'preview', 'headers_type', 'options','advanced_mode', 'debug']) + self.assertItemsEqual(list(result), ['matches', 'headers', 'fields', 'preview', 'headers_type', 'options', 'debug']) @unittest.skipUnless(can_import('odf'), "ODFPY not available") def test_ods_success(self): @@ -348,7 +348,7 @@ class TestPreview(TransactionCase): ['aux', '5', '6'], ]) # Ensure we only have the response fields we expect - self.assertItemsEqual(list(result), ['matches', 'headers', 'fields', 'preview', 'headers_type', 'options', 'advanced_mode', 'debug']) + self.assertItemsEqual(list(result), ['matches', 'headers', 'fields', 'preview', 'headers_type', 'options', 'debug']) class test_convert_import_data(TransactionCase):