[IMP] account: bank statement reconciliation: correctly find reconciliation propositi...
authorArthur Maniet <ama@odoo.com>
Tue, 16 Sep 2014 10:55:02 +0000 (12:55 +0200)
committerArthur Maniet <ama@odoo.com>
Tue, 16 Sep 2014 15:03:04 +0000 (17:03 +0200)
addons/account/account_bank_statement.py
addons/account/static/src/js/account_widgets.js

index 805ce09..25cdedd 100644 (file)
@@ -544,15 +544,20 @@ class account_bank_statement_line(osv.osv):
         sign = 1
         if statement_currency == company_currency:
             amount_field = 'credit'
-            sign = -1
             if st_line.amount > 0:
                 amount_field = 'debit'
+            else:
+                sign = -1
         else:
             amount_field = 'amount_currency'
             if st_line.amount < 0:
                 sign = -1
+        if st_line.amount_currency:
+            amount = st_line.amount_currency
+        else: 
+            amount = st_line.amount
 
-        match_id = self.get_move_lines_for_reconciliation(cr, uid, st_line, excluded_ids=excluded_ids, offset=0, limit=1, additional_domain=[(amount_field, '=', (sign * st_line.amount))])
+        match_id = self.get_move_lines_for_reconciliation(cr, uid, st_line, excluded_ids=excluded_ids, offset=0, limit=1, additional_domain=[(amount_field, '=', (sign * amount))])
         if match_id:
             return [match_id[0]]
 
index d77d319..aab3787 100644 (file)
@@ -1234,14 +1234,15 @@ openerp.account = function (instance) {
             }
         },
     
-        modeChanged: function() {
+        modeChanged: function(o, val) {
             var self = this;
     
             self.$(".action_pane.active").removeClass("active");
 
-            if (self.st_line.has_no_partner && self.get("mode") === "match") {
+            if (self.st_line.has_no_partner && self.get("mode") === "match")
                 self.set("mode", "create", {silent: true});
-            }
+            if (val.oldValue === "create")
+                self.addLineBeingEdited();
     
             if (self.get("mode") === "inactive") {
                 self.$(".match").slideUp(self.animation_speed);