From 71c8b58581f68145c5a4ce20507a3c981c7a2256 Mon Sep 17 00:00:00 2001 From: Vishmita Date: Tue, 27 Nov 2012 15:32:10 +0530 Subject: [PATCH] [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 --- addons/web/controllers/main.py | 4 ++-- addons/web/static/src/js/views.js | 20 ++++++++++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index ad5dd21d0d8..e36b46ed51a 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -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): diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index 81662ac6487..ddedcdd2ff6 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -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($('
'),{ + 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 {