[FIX]Fixed the issue of raised exception not displayed when adding attachment to object if create of ir.attachment raises exception.

bzr revid: vja@tinyerp.com-20121127100210-krziqgqh1t1063ry
This commit is contained in:
Vishmita 2012-11-27 15:32:10 +05:30
parent 718b26d796
commit 71c8b58581
2 changed files with 16 additions and 8 deletions

View File

@ -1617,8 +1617,8 @@ class Binary(openerpweb.Controller):
'filename': ufile.filename,
'id': attachment_id
}
except Exception, e:
args = { 'error': e.message }
except Exception,e:
args = {'erorr':e.faultCode.split('--')[1],'title':e.faultCode.split('--')[0]}
return out % (simplejson.dumps(callback), simplejson.dumps(args))
class Action(openerpweb.Controller):

View File

@ -978,11 +978,7 @@ instance.web.Sidebar = instance.web.Widget.extend({
this.fileupload_id = _.uniqueId('oe_fileupload');
$(window).on(this.fileupload_id, function() {
var args = [].slice.call(arguments).slice(1);
if (args[0] && args[0].error) {
alert(args[0].error);
} else {
self.do_attachement_update(self.dataset, self.model_id);
}
self.do_attachement_update(self.dataset, self.model_id,args);
instance.web.unblockUI();
});
},
@ -1092,9 +1088,21 @@ instance.web.Sidebar = instance.web.Widget.extend({
});
});
},
do_attachement_update: function(dataset, model_id) {
do_attachement_update: function(dataset, model_id,args) {
var self = this;
this.dataset = dataset;
this.model_id = model_id;
if (args && args[0]["erorr"]) {
instance.web.dialog($('<div>'),{
modal: true,
title: "OpenERP " + _.str.capitalize(args[0]["title"]),
buttons: [{
text: _t("Ok"),
click: function(){
$(this).dialog("close");
}}]
}).html(args[0]["erorr"]);
}
if (!model_id) {
this.on_attachments_loaded([]);
} else {