summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorjbm-odoo <jbm@odoo.com>2019-08-22 08:38:16 +0000
committerjbm-odoo <jbm@odoo.com>2019-08-23 08:43:12 +0000
commite1e63d018e43d79e0d0db99bd2ae1a83b1aa0ec2 (patch)
tree299378eac5a59e9c74f07f10ea127921aa2e828a /addons
parent57aa34490db4e1dd2be708180b6176616116af81 (diff)
[FIX] import: Avoid empty error message
Diffstat (limited to 'addons')
-rw-r--r--addons/base_import/models/base_import.py5
-rw-r--r--addons/base_import/static/src/js/import_action.js20
-rw-r--r--addons/base_import/static/src/scss/base_import.scss4
3 files changed, 18 insertions, 11 deletions
diff --git a/addons/base_import/models/base_import.py b/addons/base_import/models/base_import.py
index a9cc382871e..d3c932e0358 100644
--- a/addons/base_import/models/base_import.py
+++ b/addons/base_import/models/base_import.py
@@ -918,6 +918,11 @@ class Import(models.TransientModel):
'column_name': column_name,
'field_name': fields[index]
})
+ if 'name' in import_fields:
+ index_of_name = import_fields.index('name')
+ import_result['name'] = [x[index_of_name] for x in data]
+ else:
+ import_result['name'] = []
return import_result
diff --git a/addons/base_import/static/src/js/import_action.js b/addons/base_import/static/src/js/import_action.js
index a4a4db8d690..53e3c42cfa1 100644
--- a/addons/base_import/static/src/js/import_action.js
+++ b/addons/base_import/static/src/js/import_action.js
@@ -104,6 +104,10 @@ var DataImport = AbstractAction.extend({
e.preventDefault();
$(e.target).parent().parent().toggleClass('oe_import_report_showmore');
},
+ 'click .oe_import_report_see_possible_value': function (e) {
+ e.preventDefault();
+ $(e.target).parent().toggleClass('oe_import_report_showmore');
+ },
'click .oe_import_moreinfo_action a': function (e) {
e.preventDefault();
// #data will parse the attribute on its own, we don't like
@@ -140,7 +144,6 @@ var DataImport = AbstractAction.extend({
this.session = session;
this._title = _t('Import a File'); // Displayed in the breadcrumbs
this.do_not_change_match = false;
- this.preview = [[]];
},
/**
* @override
@@ -375,8 +378,6 @@ var DataImport = AbstractAction.extend({
this.$('input.oe_import_advanced_mode').prop('checked', result.advanced_mode);
this.$('.oe_import_grid').html(QWeb.render('ImportView.preview', result));
- this.preview = result.preview;
-
if (result.headers.length === 1) {
this.$('.oe_import_options').show();
this.onresults(null, null, null, {'messages': [{
@@ -457,6 +458,7 @@ var DataImport = AbstractAction.extend({
});
},
generate_fields_completion: function (root, index) {
+ var self = this;
var basic = [];
var regulars = [];
var o2m = [];
@@ -628,11 +630,9 @@ var DataImport = AbstractAction.extend({
this.trigger_up('history_back');
},
onresults: function (event, from, to, results) {
- var self = this;
var fields = this.$('.oe_import_fields input.oe_import_match_field').map(function (index, el) {
return $(el).select2('val') || false;
}).get();
- var nameIndex = _.indexOf(fields, 'name');
var message = results.messages;
var no_messages = _.isEmpty(message);
@@ -664,8 +664,8 @@ var DataImport = AbstractAction.extend({
var from = rows.from + offset;
var to = rows.to + offset;
var rowName = '';
- if (nameIndex !== -1) {
- rowName = _.str.sprintf(' (%s)', self.preview[rows.from][nameIndex]);
+ if (results.name.length > rows.from && results.name[rows.from] !== '') {
+ rowName = _.str.sprintf(' (%s)', results.name[rows.from]);
}
if (from === to) {
return _.str.sprintf(_t("at row %d%s"), from, rowName);
@@ -677,8 +677,8 @@ var DataImport = AbstractAction.extend({
var from = rows.from + offset;
var to = rows.to + offset;
var rowName = '';
- if (nameIndex !== -1) {
- rowName = _.str.sprintf(' (%s)', self.preview[rows.from][nameIndex]);
+ if (results.name.length > rows.from && results.name[rows.from] !== '') {
+ rowName = _.str.sprintf(' (%s)', results.name[rows.from]);
}
if (from === to) {
return _.str.sprintf(_t("Row %d%s"), from, rowName);
@@ -701,7 +701,7 @@ var DataImport = AbstractAction.extend({
}
if (msg instanceof Array) {
return _.str.sprintf(
- '<div class="oe_import_moreinfo oe_import_moreinfo_choices"><a href="#" class="oe_import_report_count oe_import_see_all"><i class="fa fa-arrow-right"/> %s </a><ul class="oe_import_report_more">%s</ul></div>',
+ '<div class="oe_import_moreinfo oe_import_moreinfo_choices"><a href="#" class="oe_import_report_see_possible_value oe_import_see_all"><i class="fa fa-arrow-right"/> %s </a><ul class="oe_import_report_more">%s</ul></div>',
_.str.escapeHTML(_t("See possible values")),
_(msg).map(function (msg) {
return '<li>'
diff --git a/addons/base_import/static/src/scss/base_import.scss b/addons/base_import/static/src/scss/base_import.scss
index 68d9603a813..52ab478c70f 100644
--- a/addons/base_import/static/src/scss/base_import.scss
+++ b/addons/base_import/static/src/scss/base_import.scss
@@ -73,7 +73,9 @@
display: table;
}
&.oe_import_error .oe_import_error_report,
- &.oe_import_noheaders .oe_import_noheaders,
+ &.oe_import_noheaders .oe_import_noheaders{
+ display: block;
+ }
.oe_import_report_showmore .oe_import_report_more {
display: list-item;
}