From 06f5a10f64a5e552ea12858455d52eb52eb54b24 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Tue, 19 Aug 2014 15:46:23 +0200 Subject: [PATCH] account_balance_line: Port to new API --- account_balance_line/README.rst | 55 +++++++++++++++++++++++ account_balance_line/__init__.py | 20 +-------- account_balance_line/__openerp__.py | 20 +-------- account_balance_line/account_move_line.py | 29 +++++------- 4 files changed, 70 insertions(+), 54 deletions(-) create mode 100644 account_balance_line/README.rst diff --git a/account_balance_line/README.rst b/account_balance_line/README.rst new file mode 100644 index 000000000..b4cd7a934 --- /dev/null +++ b/account_balance_line/README.rst @@ -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 `_. +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 `_. + +Credits +======= + +Contributors +------------ + +* Vincent revaville +* Yannick Vaucher + +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. diff --git a/account_balance_line/__init__.py b/account_balance_line/__init__.py index 373e5a269..0c1006db3 100644 --- a/account_balance_line/__init__.py +++ b/account_balance_line/__init__.py @@ -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 . -# -############################################################################## + from . import account_move_line diff --git a/account_balance_line/__openerp__.py b/account_balance_line/__openerp__.py index 45e2a8583..907317dfd 100644 --- a/account_balance_line/__openerp__.py +++ b/account_balance_line/__openerp__.py @@ -18,33 +18,17 @@ # along with this program. If not, see . # ############################################################################## + {'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 -* Yannick Vaucher -""", 'website': 'http://www.camptocamp.com', 'data': ['account_move_line_view.xml'], 'tests': [], 'installable': True, - 'auto_install': False, 'license': 'AGPL-3', - 'application': False, } diff --git a/account_balance_line/account_move_line.py b/account_balance_line/account_move_line.py index e6c77260e..aa7d38ec9 100644 --- a/account_balance_line/account_move_line.py +++ b/account_balance_line/account_move_line.py @@ -18,25 +18,20 @@ # along with this program. If not, see . # ############################################################################## -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'))