account_balance_line: Port to new API

This commit is contained in:
Alexis de Lattre
2014-08-19 15:46:23 +02:00
committed by Pedro M. Baeza
parent fe9a70c124
commit 81a29296c0
4 changed files with 70 additions and 54 deletions

View File

@@ -0,0 +1,55 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
====================
Account Balance Line
====================
Add a balance total for grouped lines in move line view.
Balance field will only be shown when move lines are grouped by account
or filtered by account.
Usage
=====
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/92/8.0
For further information, please visit:
* https://www.odoo.com/forum/help-1
Bug Tracker
===========
Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-financial-tools/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed feedback
`here <https://github.com/OCA/account-financial-tools/issues/new?body=module:%20account_balance_line%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Credits
=======
Contributors
------------
* Vincent revaville <vincent.renaville@camptocamp.com>
* Yannick Vaucher <yannick.vaucher@camptocamp.com>
Maintainer
----------
.. image:: http://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: http://odoo-community.org
This module is maintained by the OCA.
OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
To contribute to this module, please visit http://odoo-community.org.

View File

@@ -1,21 +1,3 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Author: Vincent Renaville (Camptocamp)
# Copyright 2010-2014 Camptocamp SA
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from . import account_move_line

View File

@@ -18,33 +18,17 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{'name': 'Balance on lines',
'summary': 'Display balance totals in move line view',
'version': '8.0.1.1.0',
'version': '8.0.1.1.1',
'author': "Camptocamp,Odoo Community Association (OCA)",
'maintainter': 'Camptocamp',
'category': 'Accounting',
'depends': ['account'],
'description': """
Balance for a line
==================
Add a balance total for grouped lines in move line view.
Balance field will only be shown when move lines are grouped by account
or filtered by account.
Contributors
------------
* Vincent revaville <vincent.renaville@camptocamp.com>
* Yannick Vaucher <yannick.vaucher@camptocamp.com>
""",
'website': 'http://www.camptocamp.com',
'data': ['account_move_line_view.xml'],
'tests': [],
'installable': True,
'auto_install': False,
'license': 'AGPL-3',
'application': False,
}

View File

@@ -18,25 +18,20 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp.osv import orm, fields
from openerp import models, fields, api
import openerp.addons.decimal_precision as dp
class account_move_line(orm.Model):
class AccountMoveLine(models.Model):
_inherit = "account.move.line"
def _line_balance(self, cr, uid, ids, field, arg, context=None):
res = {}
move_lines = self.read(cr, uid, ids,
['debit', 'credit'],
context=context)
@api.multi
@api.depends('credit', 'debit')
def _line_balance(self):
for line in self:
line.line_balance = line.debit - line.credit
for line in move_lines:
res[line['id']] = line['debit'] - line['credit']
return res
_columns = {
'line_balance': fields.function(
_line_balance, method=True,
string='Balance',
store=True),
}
line_balance = fields.Float(
compute='_line_balance', string='Balance', store=True,
digits=dp.get_precision('Account'))