Mohammed Shekha(Open ERP) has proposed merging 
lp:~openerp-dev/openerp-web/6.1-opw-581041-msh into lp:openerp-web/6.1.

Requested reviews:
  OpenERP Core Team (openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openerp-web/6.1-opw-581041-msh/+merge/130763

Hello,

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

To reproduce :-
- For the purpose of the test, do the
following in server/openerp/addons/base/ir/ir_attachment.py :
add
the following line as first line in method create (line 125):

raise
osv.except_osv("ValueError", "We cannot save your file for
some reason.")

- go to Customers (or any other object)
- add an attachment on the new created
partner by clicking "Add" button on its form view from sidebar.

Expected :- It should display the warning message.

This branch will fix this and display the warning message.

Thanks.
-- 
https://code.launchpad.net/~openerp-dev/openerp-web/6.1-opw-581041-msh/+merge/130763
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openerp-web/6.1-opw-581041-msh.
=== modified file 'addons/web/controllers/main.py'
--- addons/web/controllers/main.py	2012-08-31 11:34:18 +0000
+++ addons/web/controllers/main.py	2012-10-22 10:01:21 +0000
@@ -1522,7 +1522,7 @@
                 'id':  attachment_id
             }
         except Exception, e:
-            args = { 'error': e.message }
+            args = { 'error': e.faultCode }
         return out % (simplejson.dumps(callback), simplejson.dumps(args))
 
 class Action(openerpweb.Controller):

=== modified file 'addons/web/static/src/js/view_form.js'
--- addons/web/static/src/js/view_form.js	2012-09-24 15:26:28 +0000
+++ addons/web/static/src/js/view_form.js	2012-10-22 10:01:21 +0000
@@ -812,7 +812,7 @@
             return _.str.sprintf(_t("Delete the attachment %s"), name);
         };
     },
-    do_update: function() {
+    do_update: function(args) {
         if (!this.view.datarecord.id) {
             this.on_attachments_loaded([]);
         } else {
@@ -824,6 +824,9 @@
                     ['type', 'in', ['binary', 'url']]
                 ])).read_slice(['name', 'url', 'type'], {}).then(this.on_attachments_loaded);
         }
+        if(args && args.error){
+            alert(args.error);
+        }
     },
     on_attachments_loaded: function(attachments) {
         this.attachments = attachments;

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : openerp-dev-gtk@lists.launchpad.net
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to