From fb9e05b5b9f7fde9df5e804d7ddfe9ff543a9828 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Fri, 11 Dec 2015 13:50:42 +0100 Subject: [PATCH] Add module account_invoice_margin_report --- account_invoice_margin_report/__init__.py | 3 ++ account_invoice_margin_report/__openerp__.py | 41 +++++++++++++++++++ .../report/__init__.py | 3 ++ .../report/invoice_report.py | 39 ++++++++++++++++++ 4 files changed, 86 insertions(+) create mode 100644 account_invoice_margin_report/__init__.py create mode 100644 account_invoice_margin_report/__openerp__.py create mode 100644 account_invoice_margin_report/report/__init__.py create mode 100644 account_invoice_margin_report/report/invoice_report.py diff --git a/account_invoice_margin_report/__init__.py b/account_invoice_margin_report/__init__.py new file mode 100644 index 0000000..006edd3 --- /dev/null +++ b/account_invoice_margin_report/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import report diff --git a/account_invoice_margin_report/__openerp__.py b/account_invoice_margin_report/__openerp__.py new file mode 100644 index 0000000..fb2e1f0 --- /dev/null +++ b/account_invoice_margin_report/__openerp__.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Account Invoice Margin Report module for Odoo +# Copyright (C) 2015 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# +# 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 . +# +############################################################################## + + +{ + 'name': 'Account Invoice Margin Report', + 'version': '0.1', + 'category': 'Accounting & Finance', + 'license': 'AGPL-3', + 'summary': 'Add margin du Invoices Analysis', + 'description': """ +This module adds the margin in the Invoices Analysis pivot table. It is in a separate module because it depends on the module *bi_invoice_company_currency* (in which I re-wrote the Invoice Analysis pivot table). + +This module has been written by Alexis de Lattre from Akretion +. + """, + 'author': 'Akretion', + 'website': 'http://www.akretion.com', + 'depends': ['account_invoice_margin', 'bi_invoice_company_currency'], + 'data': [], + 'installable': True, +} diff --git a/account_invoice_margin_report/report/__init__.py b/account_invoice_margin_report/report/__init__.py new file mode 100644 index 0000000..dfd744c --- /dev/null +++ b/account_invoice_margin_report/report/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import invoice_report diff --git a/account_invoice_margin_report/report/invoice_report.py b/account_invoice_margin_report/report/invoice_report.py new file mode 100644 index 0000000..3a85e34 --- /dev/null +++ b/account_invoice_margin_report/report/invoice_report.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Account Invoice Margin Report module for Odoo +# Copyright (C) 2015 Akretion (http://www.akretion.com/) +# @author Alexis de Lattre +# +# 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 openerp import models, fields +import openerp.addons.decimal_precision as dp + + +class AccountInvoiceReportBi(models.Model): + _inherit = "account.invoice.report.bi" + + margin_company_currency = fields.Float( + string='Margin', readonly=True, + digits=dp.get_precision('Account')) + + def _select(self): + select = super(AccountInvoiceReportBi, self)._select() + select += """ + , sum(ail.margin_company_currency) AS margin_company_currency + """ + return select