From 9c9826ee4be275b9f3c2b732eff487bc14fabf58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Tue, 16 Sep 2014 18:49:55 +0200 Subject: [PATCH] [IMP] move account.move.line.get_balance() to account_banking_payment_export --- .../account_banking/account_banking.py | 19 ---------- .../models/account_move_line.py | 35 ++++++++++++++----- 2 files changed, 26 insertions(+), 28 deletions(-) diff --git a/__unported__/account_banking/account_banking.py b/__unported__/account_banking/account_banking.py index 9aec2d8f8..829befc29 100644 --- a/__unported__/account_banking/account_banking.py +++ b/__unported__/account_banking/account_banking.py @@ -662,22 +662,3 @@ class invoice(orm.Model): 'Reference Type', required=True ) } - - -class account_move_line(orm.Model): - _inherit = "account.move.line" - - def get_balance(self, cr, uid, ids, context=None): - """ - Return the balance of any set of move lines. - - Not to be confused with the 'balance' field on this model, which - returns the account balance that the move line applies to. - """ - total = 0.0 - if not ids: - return total - for line in self.read( - cr, uid, ids, ['debit', 'credit'], context=context): - total += (line['debit'] or 0.0) - (line['credit'] or 0.0) - return total diff --git a/account_banking_payment_export/models/account_move_line.py b/account_banking_payment_export/models/account_move_line.py index 74bb47f81..09b4f6140 100644 --- a/account_banking_payment_export/models/account_move_line.py +++ b/account_banking_payment_export/models/account_move_line.py @@ -23,18 +23,35 @@ from openerp.osv import orm, fields from operator import itemgetter -# All the code below aims at fixing one small issue in _to_pay_search() -# But _to_pay_search() is the search function of the field 'amount_to_pay' -# which is a field.function and these functions are not inheritable in OpenERP. -# So we have to inherit the field 'amount_to_pay' and duplicate the related -# functions -# If the patch that I proposed in this bug report -# https://bugs.launchpad.net/openobject-addons/+bug/1275478 -# is integrated in addons/account_payment, then we will be able to remove this -# file. -- Alexis de Lattre class AccountMoveLine(orm.Model): _inherit = 'account.move.line' + def get_balance(self, cr, uid, ids, context=None): + """ + Return the balance of any set of move lines. + + Not to be confused with the 'balance' field on this model, which + returns the account balance that the move line applies to. + """ + total = 0.0 + if not ids: + return total + for line in self.read( + cr, uid, ids, ['debit', 'credit'], context=context): + total += (line['debit'] or 0.0) - (line['credit'] or 0.0) + return total + + # All the code below aims at fixing one small issue in _to_pay_search() + # But _to_pay_search() is the search function of the field 'amount_to_pay' + # which is a field.function and these functions are not inheritable in + # OpenERP. + # So we have to inherit the field 'amount_to_pay' and duplicate the related + # functions + # If the patch that I proposed in this bug report + # https://bugs.launchpad.net/openobject-addons/+bug/1275478 + # is integrated in addons/account_payment, then we will be able to remove + # this file. -- Alexis de Lattre + def _amount_to_pay(self, cr, uid, ids, name, arg=None, context=None): """ Return the amount still to pay regarding all the payemnt orders (excepting cancelled orders)"""