Add module sale_margin_report

This commit is contained in:
Alexis de Lattre
2016-01-08 16:57:30 +01:00
parent 823e9ad208
commit 32553d0042
4 changed files with 86 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from . import report

View File

@@ -0,0 +1,41 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Sale Margin Report module for Odoo
# Copyright (C) 2016 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
#
# 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/>.
#
##############################################################################
{
'name': 'Sale Margin Report',
'version': '0.1',
'category': 'Sales Management',
'license': 'AGPL-3',
'summary': 'Add margin measure in Sales Analysis',
'description': """
This module adds the measure *Margin* in the Sales Analysis pivot table. It is in a separate module because it depends on the module *bi_sale_company_currency* (in which I re-wrote the Sales Analysis pivot table).
This module has been written by Alexis de Lattre from Akretion
<alexis.delattre@akretion.com>.
""",
'author': 'Akretion',
'website': 'http://www.akretion.com',
'depends': ['sale_margin_no_onchange', 'bi_sale_company_currency'],
'data': [],
'installable': True,
}

View File

@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from . import sale_report

View File

@@ -0,0 +1,39 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Sale Margin Report module for Odoo
# Copyright (C) 2016 Akretion (http://www.akretion.com/)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
#
# 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 openerp import models, fields
import openerp.addons.decimal_precision as dp
class SaleReportBi(models.Model):
_inherit = "sale.report.bi"
margin_company_currency = fields.Float(
string='Margin', readonly=True,
digits=dp.get_precision('Account'))
def _select(self):
select = super(SaleReportBi, self)._select()
select += """
, sum(sol.margin_company_currency) AS margin_company_currency
"""
return select