From ce32867a90bdc56b529db9f6c7cceef0d93b66e0 Mon Sep 17 00:00:00 2001 From: Arthur Maniet Date: Tue, 5 May 2015 09:49:53 +0200 Subject: [PATCH] [FIX] account: bank statement reconciliation: - ctrl-enter only persist balanced reconciliations - give a reconciliation proposition only if there's an unambiguous match - added some missing tanslations - use default order to display statement lines in reconciliation widget --- addons/account/account_bank_statement.py | 8 ++++---- addons/account/static/src/js/account_widgets.js | 9 ++++----- .../src/xml/account_bank_statement_reconciliation.xml | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/addons/account/account_bank_statement.py b/addons/account/account_bank_statement.py index b39b999e82c..b4ccea8ba20 100644 --- a/addons/account/account_bank_statement.py +++ b/addons/account/account_bank_statement.py @@ -540,8 +540,8 @@ class account_bank_statement_line(osv.osv): # Look for structured communication if st_line.name: domain = self._domain_reconciliation_proposition(cr, uid, st_line, excluded_ids=excluded_ids, context=context) - match_id = mv_line_pool.search(cr, uid, domain, offset=0, limit=1, context=context) - if match_id: + match_id = mv_line_pool.search(cr, uid, domain, offset=0, limit=2, context=context) + if match_id and len(match_id) == 1: mv_line_br = mv_line_pool.browse(cr, uid, match_id, context=context) target_currency = st_line.currency_id or st_line.journal_id.currency or st_line.journal_id.company_id.currency_id mv_line = mv_line_pool.prepare_move_lines_for_reconciliation_widget(cr, uid, mv_line_br, target_currency=target_currency, target_date=st_line.date, context=context)[0] @@ -571,8 +571,8 @@ class account_bank_statement_line(osv.osv): # Look for a matching amount domain_exact_amount = domain + [(amount_field, '=', float_round(sign * amount, precision_digits=precision_digits))] - match_id = self.get_move_lines_for_reconciliation(cr, uid, st_line, excluded_ids=excluded_ids, offset=0, limit=1, additional_domain=domain_exact_amount) - if match_id: + match_id = self.get_move_lines_for_reconciliation(cr, uid, st_line, excluded_ids=excluded_ids, offset=0, limit=2, additional_domain=domain_exact_amount) + if match_id and len(match_id) == 1: return match_id if not st_line.partner_id.id: diff --git a/addons/account/static/src/js/account_widgets.js b/addons/account/static/src/js/account_widgets.js index 146ba5eadc8..bbef41e98ed 100644 --- a/addons/account/static/src/js/account_widgets.js +++ b/addons/account/static/src/js/account_widgets.js @@ -180,7 +180,6 @@ openerp.account = function (instance) { deferred_promises.push(self.model_bank_statement_line .query(['id']) .filter(lines_filter) - .order_by('statement_id, id') .all().then(function (data) { self.st_lines = _(data).map(function(o){ return o.id }); }) @@ -289,7 +288,7 @@ openerp.account = function (instance) { keyboardShortcutsHandler: function(e) { var self = this; if ((e.which === 13 || e.which === 10) && (e.ctrlKey || e.metaKey)) { - self.persistReconciliations(_.filter(self.getChildren(), function(o) { return o.is_valid; })); + self.persistReconciliations(_.filter(self.getChildren(), function(o) { return o.get("balance").toFixed(3) === "0.000"; })); } }, @@ -519,7 +518,7 @@ openerp.account = function (instance) { var time_taken; if (sec_taken/60 >= 1) time_taken = Math.floor(sec_taken/60) +"' "+ sec_taken%60 +"''"; - else time_taken = sec_taken%60 +" seconds"; + else time_taken = sec_taken%60 +_t(" seconds"); var title; if (sec_per_item < 5) title = _t("Whew, that was fast !") + " "; @@ -1277,7 +1276,7 @@ openerp.account = function (instance) { self.is_valid = false; self.$(".tip_reconciliation_not_balanced").show(); self.$(".tbody_open_balance").empty(); - self.$(".button_ok").text("OK").removeClass("oe_highlight").attr("disabled", "disabled"); + self.$(".button_ok").text(_t("OK")).removeClass("oe_highlight").attr("disabled", "disabled"); // Find out if the counterpart is lower than, equal or greater than the transaction being reconciled var balance_type = undefined; @@ -1294,7 +1293,7 @@ openerp.account = function (instance) { if (self.st_line.has_no_partner) { createOpenBalance(_t("Choose counterpart")); } else { - displayValidState(false, "Keep open"); + displayValidState(false, _t("Keep open")); createOpenBalance(_t("Open balance")); } } diff --git a/addons/account/static/src/xml/account_bank_statement_reconciliation.xml b/addons/account/static/src/xml/account_bank_statement_reconciliation.xml index 68813e9a8e6..c142fcda2bd 100644 --- a/addons/account/static/src/xml/account_bank_statement_reconciliation.xml +++ b/addons/account/static/src/xml/account_bank_statement_reconciliation.xml @@ -33,7 +33,7 @@
-

Tip : Hit ctrl-enter to validate the whole sheet.

+

Tip : Hit ctrl-enter to reconcile all balanced items.