[FIX] account: bank statement reconciliation widget: disable buttons which trigger...
authorArthur Maniet <me@whisno.be>
Wed, 26 Nov 2014 08:44:50 +0000 (09:44 +0100)
committerArthur Maniet <me@whisno.be>
Wed, 26 Nov 2014 08:44:50 +0000 (09:44 +0100)
addons/account/static/src/js/account_widgets.js

index 04189e3..171c92c 100644 (file)
@@ -278,12 +278,15 @@ openerp.account = function (instance) {
             if (! self.single_statement) return;
             var name = self.$(".change_statement_name_field").val();
             if (name === "") return;
+            self.$(".change_statement_name_button").attr("disabled", "disabled");
             return self.model_bank_statement
                 .call("write", [[self.statement_ids[0]], {'name': name}])
-                .then(function () {
+                .done(function () {
                     self.title = name;
                     self.$(".statement_name span").text(name).show();
                     self.$(".change_statement_name_container").hide();
+                }).always(function() {
+                    self.$(".change_statement_name_button").removeAttr("disabled");
                 });
         },
     
@@ -1660,9 +1663,10 @@ openerp.account = function (instance) {
             var deferred_animation = self.$el.parent().slideUp(speed*height/150);
     
             // RPC
+            self.$(".button_ok").attr("disabled", "disabled");
             return self.model_bank_statement_line
                 .call("process_reconciliation", [self.st_line_id, self.makeMoveLineDicts()])
-                .then(function () {
+                .done(function () {
                     self.getParent().unexcludeMoveLines(self, self.partner_id, self.get("mv_lines_selected"));
                     $.each(self.$(".bootstrap_popover"), function(){ $(this).popover('destroy') });
                     return $.when(deferred_animation).then(function(){
@@ -1672,10 +1676,12 @@ openerp.account = function (instance) {
                             parent.childValidated(self);
                         });
                     });
-                }, function(){
+                }).fail(function(){
                     self.$el.parent().slideDown(speed*height/150, function(){
                         self.$el.unwrap();
                     });
+                }).always(function() {
+                    self.$(".button_ok").removeAttr("disabled");
                 });
         },
     });