1
# -*- encoding: utf-8 -*-
2
##############################################################################
4
# Copyright (c) 2014 SF Soluciones.
5
# (http://www.sfsoluciones.com)
6
# contacto@sfsoluciones.com
8
# This program is free software: you can redistribute it and/or modify
9
# it under the terms of the GNU General Public License as published by
10
# the Free Software Foundation, either version 3 of the License, or
11
# (at your option) any later version.
13
# This program is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
# GNU General Public License for more details.
18
# You should have received a copy of the GNU General Public License
19
# along with this program. If not, see <http://www.gnu.org/licenses/>.
21
##############################################################################
23
from openerp.osv import fields, osv, orm
24
import openerp.addons.decimal_precision as dp
26
class account_move_line(osv.osv):
27
_inherit = "account.move.line"
29
def _compute_balance(self, cr, uid, ids, name, args, context=None):
32
for line in self.browse(cr, uid, ids, context=context):
35
for payment_line in line.reconcile_id.line_id:
36
balance += (payment_line.debit - payment_line.credit)
37
elif line.reconcile_partial_id:
38
for payment_line in line.reconcile_partial_id.line_partial_ids:
39
balance += (payment_line.debit - payment_line.credit)
40
res[line.id] = balance
43
def _get_line_from_reconcile(self, cr, uid, ids, context=None):
45
for r in self.pool.get('account.move.reconcile').browse(cr, uid, ids, context=context):
46
for line in r.line_partial_ids:
47
result[line.id] = True
48
for line in r.line_id:
49
result[line.id] = True
53
'tot_balance':fields.function(_compute_balance, digits_compute=dp.get_precision('Account'), string='Balance',
55
'account.move.line': (lambda self, cr, uid, ids, c={}: ids, ['debit','credit','reconcile_id','reconcile_partial_id'], 20),
56
'account.move.reconcile': (_get_line_from_reconcile, None, 20),
68
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: