From b9eafcde227a21f2e7a6e4c796cc440244bfd24f Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Thu, 11 Apr 2013 14:55:25 +0200 Subject: [PATCH] [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 --- addons/account_report_company/__init__.py | 25 +++++++++ addons/account_report_company/__openerp__.py | 56 +++++++++++++++++++ .../account_report_company/account_invoice.py | 31 ++++++++++ .../account_invoice_view.xml | 24 ++++++++ .../account_report_company/report/__init__.py | 24 ++++++++ .../report/account_invoice_report.py | 36 ++++++++++++ .../report/account_invoice_report_view.xml | 24 ++++++++ 7 files changed, 220 insertions(+) create mode 100644 addons/account_report_company/__init__.py create mode 100644 addons/account_report_company/__openerp__.py create mode 100644 addons/account_report_company/account_invoice.py create mode 100644 addons/account_report_company/account_invoice_view.xml create mode 100644 addons/account_report_company/report/__init__.py create mode 100644 addons/account_report_company/report/account_invoice_report.py create mode 100644 addons/account_report_company/report/account_invoice_report_view.xml diff --git a/addons/account_report_company/__init__.py b/addons/account_report_company/__init__.py new file mode 100644 index 00000000000..623cb467c25 --- /dev/null +++ b/addons/account_report_company/__init__.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Business Applications +# Copyright (c) 2013 OpenERP S.A. +# +# 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 . +# +############################################################################## + +import account_invoice +import report + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_report_company/__openerp__.py b/addons/account_report_company/__openerp__.py new file mode 100644 index 00000000000..9ee15e1556c --- /dev/null +++ b/addons/account_report_company/__openerp__.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Business Applications +# Copyright (c) 2013 OpenERP S.A. +# +# 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': '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: diff --git a/addons/account_report_company/account_invoice.py b/addons/account_report_company/account_invoice.py new file mode 100644 index 00000000000..aae1ee77d0e --- /dev/null +++ b/addons/account_report_company/account_invoice.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Business Applications +# Copyright (c) 2013 S.A. +# +# 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.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") + } \ No newline at end of file diff --git a/addons/account_report_company/account_invoice_view.xml b/addons/account_report_company/account_invoice_view.xml new file mode 100644 index 00000000000..2db2d77ad87 --- /dev/null +++ b/addons/account_report_company/account_invoice_view.xml @@ -0,0 +1,24 @@ + + + + + account.invoice + + + + + + + + + + account.invoice + + + + + + + + + \ No newline at end of file diff --git a/addons/account_report_company/report/__init__.py b/addons/account_report_company/report/__init__.py new file mode 100644 index 00000000000..0fa7453c913 --- /dev/null +++ b/addons/account_report_company/report/__init__.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Business Applications +# Copyright (c) 2013 OpenERP S.A. +# +# 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 . +# +############################################################################## + +import account_invoice_report + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_report_company/report/account_invoice_report.py b/addons/account_report_company/report/account_invoice_report.py new file mode 100644 index 00000000000..09cf1caca83 --- /dev/null +++ b/addons/account_report_company/report/account_invoice_report.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Business Applications +# Copyright (c) 2013 OpenERP S.A. +# +# 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.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" diff --git a/addons/account_report_company/report/account_invoice_report_view.xml b/addons/account_report_company/report/account_invoice_report_view.xml new file mode 100644 index 00000000000..bfdc99b1361 --- /dev/null +++ b/addons/account_report_company/report/account_invoice_report_view.xml @@ -0,0 +1,24 @@ + + + + + account.invoice.report + + + + + + + + + + account.invoice.report + + + + + + + + + \ No newline at end of file