From c6ca31dd9f284eea315320e9728bf5e6145df2b9 Mon Sep 17 00:00:00 2001 From: Arthur Maniet Date: Tue, 16 Sep 2014 12:55:02 +0200 Subject: [PATCH] [IMP] account: bank statement reconciliation: correctly find reconciliation proposition based on amount match --- addons/account/account_bank_statement.py | 9 +++++++-- addons/account/static/src/js/account_widgets.js | 7 ++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/addons/account/account_bank_statement.py b/addons/account/account_bank_statement.py index 805ce093321..25cdeddfad8 100644 --- a/addons/account/account_bank_statement.py +++ b/addons/account/account_bank_statement.py @@ -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]] diff --git a/addons/account/static/src/js/account_widgets.js b/addons/account/static/src/js/account_widgets.js index d77d31915eb..aab3787c6e8 100644 --- a/addons/account/static/src/js/account_widgets.js +++ b/addons/account/static/src/js/account_widgets.js @@ -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);