From 197ce282bd8874bc608677f308bb9e1c2551cc17 Mon Sep 17 00:00:00 2001 From: Arthur Maniet Date: Tue, 16 Sep 2014 17:15:54 +0200 Subject: [PATCH] [IMP] account: bank statement reconciliation widget: ctrl-enter makes only 1 RPC call --- addons/account/account_bank_statement.py | 6 +- .../account_bank_statement_reconciliation.css | 5 +- ...account_bank_statement_reconciliation.scss | 5 +- .../account/static/src/js/account_widgets.js | 99 ++++++++++++++++--- 4 files changed, 92 insertions(+), 23 deletions(-) diff --git a/addons/account/account_bank_statement.py b/addons/account/account_bank_statement.py index 25cdeddfad800..93bc9b7ab3edd 100644 --- a/addons/account/account_bank_statement.py +++ b/addons/account/account_bank_statement.py @@ -554,7 +554,7 @@ def get_reconciliation_proposition(self, cr, uid, st_line, excluded_ids=None, co sign = -1 if st_line.amount_currency: amount = st_line.amount_currency - else: + 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 * amount))]) @@ -650,6 +650,10 @@ def get_currency_rate_line(self, cr, uid, st_line, currency_diff, move_id, conte 'account_id': account_id } + def process_reconciliations(self, cr, uid, data, context=None): + for datum in data: + self.process_reconciliation(cr, uid, datum[0], datum[1], context=context) + def process_reconciliation(self, cr, uid, id, mv_line_dicts, context=None): """ Creates a move line for each item of mv_line_dicts and for the statement line. Reconcile a new move line with its counterpart_move_line_id if specified. Finally, mark the statement line as reconciled by putting the newly created move id in the column journal_entry_id. diff --git a/addons/account/static/src/css/account_bank_statement_reconciliation.css b/addons/account/static/src/css/account_bank_statement_reconciliation.css index 2db4acd4e3dfe..fb7de387b002d 100644 --- a/addons/account/static/src/css/account_bank_statement_reconciliation.css +++ b/addons/account/static/src/css/account_bank_statement_reconciliation.css @@ -137,9 +137,8 @@ transform: rotate(90deg); } .openerp .oe_bank_statement_reconciliation .oe_bank_statement_reconciliation_line .partner_name .change_partner { display: none; - cursor: pointer; } - .openerp .oe_bank_statement_reconciliation .oe_bank_statement_reconciliation_line .partner_name .change_partner .glyphicon { - margin: 0 5px; } + cursor: pointer; + margin: 0 10px 0 5px; } .openerp .oe_bank_statement_reconciliation .oe_bank_statement_reconciliation_line .partner_name:hover .change_partner { display: inline; } .openerp .oe_bank_statement_reconciliation .oe_bank_statement_reconciliation_line .change_partner_container { diff --git a/addons/account/static/src/css/account_bank_statement_reconciliation.scss b/addons/account/static/src/css/account_bank_statement_reconciliation.scss index 6ff1cc7449db8..f8fcc7c0b4d16 100644 --- a/addons/account/static/src/css/account_bank_statement_reconciliation.scss +++ b/addons/account/static/src/css/account_bank_statement_reconciliation.scss @@ -200,10 +200,7 @@ $aestetic_animation_speed: 300ms; .change_partner { display: none; cursor: pointer; - - .glyphicon { - margin: 0 5px; - } + margin: 0 10px 0 5px; } &:hover .change_partner { display: inline; diff --git a/addons/account/static/src/js/account_widgets.js b/addons/account/static/src/js/account_widgets.js index aab3787c6e868..3f55575e47d70 100644 --- a/addons/account/static/src/js/account_widgets.js +++ b/addons/account/static/src/js/account_widgets.js @@ -283,12 +283,79 @@ openerp.account = function (instance) { keyboardShortcutsHandler: function(e) { var self = this; if ((e.which === 13 || e.which === 10) && (e.ctrlKey || e.metaKey)) { - $.each(self.getChildren(), function(i, o){ - if (o.is_valid && o.persistAndDestroy()) { - self.lines_reconciled_with_ctrl_enter++; + self.persistReconciliations(_.filter(self.getChildren(), function(o) { return o.is_valid; })); + } + }, + + persistReconciliations: function(reconciliations) { + if (reconciliations.length === 0) return; + var self = this; + // Prepare data + var data = []; + for (var i=0; i