From 8049d1e855204c64b56577ecdc32f838f494474c Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Thu, 9 Jun 2016 14:57:16 +0200 Subject: [PATCH] [FIX] base_import: file type on Windows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a user imports a CSV file on Windows, the "CSV Format Options…" field does not appear. This is an issue since it might be necessary to tune these options depending on the file, e.g. change the encoding. For some unknown reason, on Windows, the file type is empty whatever the browser used. Therefore, we fall back on the extension of the file. opw-680347 --- addons/base_import/static/src/js/import.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/addons/base_import/static/src/js/import.js b/addons/base_import/static/src/js/import.js index 5c57ff708f5..1451e073473 100644 --- a/addons/base_import/static/src/js/import.js +++ b/addons/base_import/static/src/js/import.js @@ -237,7 +237,12 @@ var DataImport = Widget.extend(ControlPanelMixin, { if (!this.$('input.oe_import_file').val()) { return; } this.$el.removeClass('oe_import_preview oe_import_error'); - this.$el.find('.oe_import_toggle').toggle((this.$('input.oe_import_file')[0].files[0].type == "text/csv")); + var import_toggle = false; + var file = this.$('input.oe_import_file')[0].files[0]; + if (file.type === "text/csv" || (file.type === "" && _.last(file.name.split('.')) === "csv")) { + import_toggle = true; + } + this.$el.find('.oe_import_toggle').toggle(import_toggle); jsonp(this.$el, { url: '/base_import/set_file' }, this.proxy('settings_changed'));