[ADD] account_report_company module: new module for adding "commercial entity" m2o on invoices and "Partner Company" dimension on Invoice Analysis

bzr revid: odo@openerp.com-20130411125525-1typd4fuuvrbobae
This commit is contained in:
Olivier Dony
2013-04-11 14:55:25 +02:00
parent 5937980b1d
commit b9eafcde22
7 changed files with 220 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Business Applications
# Copyright (c) 2013 OpenERP S.A. <http://openerp.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/>.
#
##############################################################################
import account_invoice
import report
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,56 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Business Applications
# Copyright (c) 2013 OpenERP S.A. <http://openerp.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': 'Invoice Analysis per Company',
'version': '1.0',
'category': 'Accounting & Finance',
'description': """
Add an extra Company dimension on Invoices for consolidated Invoice Analysis
============================================================================
By default Customer and Supplier invoices can be linked to a contact within
a company, but the company is not a direct reference in the database structure for
invoices. Journal Entries are however always linked to the company and not to
contacts, so that Accounts Payable and Receivable are always correct and consolidated
at company level.
When many different contacts/departments need to be invoiced within the same parent company,
this can make reporting by Company more difficult: reports are directly based on the
database structure and would not provide an aggregated company dimension.
This modules solves the problem by adding an explicit company reference on invoices,
automatically computed from the invoice contact, and use this new dimension
when grouping the list of Invoices or the Invoice Analysis report by Partner.
Note: this module will likely be removed for the next major OpenERP version and
directly integrated in the core accounting.
""",
'author': 'OpenERP SA',
'website': 'http://www.openerp.com',
'depends': ['account'],
'data': [
'account_invoice_view.xml',
'report/account_invoice_report_view.xml',
],
'auto_install': True,
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Business Applications
# Copyright (c) 2013 S.A. <http://openerp.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.osv import osv, fields
class account_invoice(osv.Model):
_inherit = 'account.invoice'
_columns = {
'partner_commercial_id': fields.related('partner_id', 'commercial_id', string='Commercial Entity', type='many2one',
relation='res.partner', store=True, readonly=True,
help="The commercial entity that will be used on Journal Entries for this invoice")
}
@@ -0,0 +1,24 @@
<?xml version="1.0"?>
<openerp>
<data>
<record model="ir.ui.view" id="account_report_company_tree_view">
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_tree"/>
<field name="arch" type="xml">
<field name="partner_id" position="after">
<field name="partner_commercial_id" invisible="1"/>
</field>
</field>
</record>
<record model="ir.ui.view" id="account_report_company_search_view">
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.view_account_invoice_filter"/>
<field name="arch" type="xml">
<filter string="Partner" position="replace">
<filter name="partner_commercial_id" string="Partner" domain="[]" context="{'group_by':'partner_commercial_id'}"/>
</filter>
</field>
</record>
</data>
</openerp>
@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Business Applications
# Copyright (c) 2013 OpenERP S.A. <http://openerp.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/>.
#
##############################################################################
import account_invoice_report
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Business Applications
# Copyright (c) 2013 OpenERP S.A. <http://openerp.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.osv import osv, fields
class account_invoice_report(osv.Model):
_inherit = 'account.invoice.report'
_columns = {
'partner_commercial_id': fields.many2one('res.partner', 'Partner Company', help="Commercial Entity"),
}
def _select(self):
return super(account_invoice_report, self)._select() + ", sub.partner_commercial_id as partner_commercial_id"
def _sub_select(self):
return super(account_invoice_report, self)._sub_select() + ", ai.partner_commercial_id as partner_commercial_id"
def _group_by(self):
return super(account_invoice_report, self)._group_by() + ", ai.partner_commercial_id"
@@ -0,0 +1,24 @@
<?xml version="1.0"?>
<openerp>
<data>
<record model="ir.ui.view" id="account_report_company_invoice_report_tree_view">
<field name="model">account.invoice.report</field>
<field name="inherit_id" ref="account.view_account_invoice_report_tree"/>
<field name="arch" type="xml">
<field name="partner_id" position="after">
<field name="partner_commercial_id" invisible="1"/>
</field>
</field>
</record>
<record model="ir.ui.view" id="account_report_company_invoice_report_search_view">
<field name="model">account.invoice.report</field>
<field name="inherit_id" ref="account.view_account_invoice_report_search"/>
<field name="arch" type="xml">
<filter name="partner" position="replace">
<filter string="Partner" name="partner_commercial_id" context="{'group_by':'partner_commercial_id','residual_visible':True}"/>
</filter>
</field>
</record>
</data>
</openerp>