[FIX] base_import: file type on Windows

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
This commit is contained in:
Nicolas Martinelli
2016-06-09 15:09:22 +02:00
parent a46f361698
commit 8049d1e855
+6 -1
View File
@@ -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'));