[FIX] base_import: don't crash UI when an unexpected exception is raised during the import process

treat exceptions as 'normal' failures, convert to a regular 'error' message

bzr revid: xmo@openerp.com-20130204125214-gy0l6qlt9obkb81x
This commit is contained in:
Xavier Morel 2013-02-04 13:52:14 +01:00
parent 2722b91ca5
commit d5a0ddc99b
1 changed files with 12 additions and 2 deletions

View File

@ -336,8 +336,18 @@ openerp.base_import = function (instance) {
var fields = this.$('.oe_import_fields input.oe_import_match_field').map(function (index, el) {
return $(el).select2('val') || false;
}).get();
return this.Import.call(
'do', [this.id, fields, this.import_options()], options);
return this.Import.call('do', [this.id, fields, this.import_options()], options)
.then(undefined, function (error, event) {
// In case of unexpected exception, convert
// "JSON-RPC error" to an import failure, and
// prevent default handling (warning dialog)
if (event) { event.preventDefault(); }
return $.when([{
type: 'error',
record: false,
message: error.data.fault_code,
}]);
}) ;
},
onvalidate: function () {
return this.call_import({ dryrun: true })