[IMP] base_import: better warnings when the file parsing has very likely failed

bzr revid: xmo@openerp.com-20121001142227-v1iypgjgfcq4pgo7
This commit is contained in:
Xavier Morel 2012-10-01 16:22:27 +02:00
parent 89be614ea3
commit 771fae90d7
2 changed files with 14 additions and 3 deletions

View File

@ -171,14 +171,24 @@ openerp.base_import = function (instance) {
'oe_import_noheaders',
!this.$('input.oe_import_has_header').prop('checked'));
if (result.error) {
this.$('.oe_import_options').show();
this.$el.addClass('oe_import_preview_error oe_import_error');
this.$('.oe_import_error_report').html(
QWeb.render('ImportView.preview.error', result));
QWeb.render('ImportView.preview.error', result))
.get(0).scrollIntoView();
return;
}
this.$el.addClass('oe_import_preview');
this.$('table').html(QWeb.render('ImportView.preview', result));
if (result.headers.length === 1) {
this.$('.oe_import_options').show();
this.render_import_result([{
type: 'warning',
message: _t("A single column was found in the file, this often means the file separator is incorrect")
}]);
}
var $fields = this.$('.oe_import_fields input');
this.render_fields_matches(result, $fields);
var data = this.generate_fields_completion(result);
@ -365,7 +375,7 @@ openerp.base_import = function (instance) {
'</div>'
].join('')
},
}));
})).get(0).scrollIntoView();
},
});
};

View File

@ -82,7 +82,8 @@
</tr>
</t>
<t t-name="ImportView.preview.error">
<p>Import preview failed due to: <t t-esc="error"/></p>
<p>Import preview failed due to: <t t-esc="error"/>. The issue is
usually an incorrect file encoding.</p>
<p>Here is the start of the file we could not import:</p>
<pre><t t-esc="preview"/></pre>
</t>