diff --git a/account_entries_report_analytic_plan/README.rst b/account_entries_report_analytic_plan/README.rst new file mode 100644 index 00000000..3731a079 --- /dev/null +++ b/account_entries_report_analytic_plan/README.rst @@ -0,0 +1,62 @@ +.. 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 + +=============================== +Analytic plans in journal items +=============================== + +This module allows you to group your journal items during analysis by the analytic plan assigned. + +Installation +============ + +To install this module, you need to: + +#. install sqlparse: ``pip install sqlparse`` +#. install the module as usual + +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/91/8.0 + +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. + +Credits +======= + +Images +------ + +* Odoo Community Association: `Icon `_. + +Contributors +------------ + +* Holger Brunn + +Do not contact contributors directly about help with questions or problems concerning this addon, but use the `community mailing list `_ or the `appropriate specialized mailinglist `_ for help, and the bug tracker linked in `Bug Tracker`_ above for technical issues. + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://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 https://odoo-community.org. diff --git a/account_entries_report_analytic_plan/__init__.py b/account_entries_report_analytic_plan/__init__.py new file mode 100644 index 00000000..7eda98a2 --- /dev/null +++ b/account_entries_report_analytic_plan/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# © 2016 Therp BV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from . import models diff --git a/account_entries_report_analytic_plan/__openerp__.py b/account_entries_report_analytic_plan/__openerp__.py new file mode 100644 index 00000000..cb4bbfad --- /dev/null +++ b/account_entries_report_analytic_plan/__openerp__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# © 2016 Therp BV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +{ + "name": "Analytic plans in journal items", + "version": "8.0.1.0.0", + "author": "Therp BV,Odoo Community Association (OCA)", + "license": "AGPL-3", + "category": "Accounting & Finance", + "summary": "Show analytic plan in journal items analysis", + "depends": [ + 'account_analytic_plans', + ], + "data": [ + "views/account_entries_report.xml", + ], + "external_dependencies": { + 'python': [ + 'sqlparse', + ], + }, +} diff --git a/account_entries_report_analytic_plan/i18n/nl.po b/account_entries_report_analytic_plan/i18n/nl.po new file mode 100644 index 00000000..4a785415 --- /dev/null +++ b/account_entries_report_analytic_plan/i18n/nl.po @@ -0,0 +1,28 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_entries_report_analytic_plan +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-09-15 16:03+0000\n" +"PO-Revision-Date: 2016-09-15 16:03+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: account_entries_report_analytic_plan +#: field:account.entries.report,analytics_id:0 +#: view:account.entries.report:account_entries_report_analytic_plan.view_account_entries_report_search +msgid "Analytic Distribution" +msgstr "Kostenverdeling" + +#. module: account_entries_report_analytic_plan +#: model:ir.model,name:account_entries_report_analytic_plan.model_account_entries_report +msgid "Journal Items Analysis" +msgstr "Analyse journaalposten" + diff --git a/account_entries_report_analytic_plan/models/__init__.py b/account_entries_report_analytic_plan/models/__init__.py new file mode 100644 index 00000000..3ebb699c --- /dev/null +++ b/account_entries_report_analytic_plan/models/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# © 2016 Therp BV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from . import account_entries_report diff --git a/account_entries_report_analytic_plan/models/account_entries_report.py b/account_entries_report_analytic_plan/models/account_entries_report.py new file mode 100644 index 00000000..3fd887dc --- /dev/null +++ b/account_entries_report_analytic_plan/models/account_entries_report.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +# © 2016 Therp BV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +import sqlparse +from psycopg2.extensions import AsIs +from openerp import fields, models + + +class AccountEntriesReport(models.Model): + _inherit = 'account.entries.report' + + analytics_id = fields.Many2one('account.analytic.plan.instance', + 'Analytic Distribution') + + def init(self, cr): + """Here, we try to be less invasive than the usual blunt overwrite of + the sql view""" + super(AccountEntriesReport, self).init(cr) + cr.execute("select pg_get_viewdef(%s::regclass)", (self._table,)) + for statement in sqlparse.parse(cr.fetchone()[0]): + current_keyword = None + for token in statement: + if token.is_keyword: + current_keyword = token + if isinstance(token, sqlparse.sql.IdentifierList) and\ + current_keyword.value == 'SELECT': + last = None + for last in token: + pass + token.insert_after(last, sqlparse.sql.Token( + sqlparse.tokens.Generic, ',l.analytics_id')) + cr.execute("create or replace view %s as (%s)", + (AsIs(self._table), AsIs(str(statement)[:-1]))) diff --git a/account_entries_report_analytic_plan/static/description/icon.png b/account_entries_report_analytic_plan/static/description/icon.png new file mode 100644 index 00000000..3a0328b5 Binary files /dev/null and b/account_entries_report_analytic_plan/static/description/icon.png differ diff --git a/account_entries_report_analytic_plan/views/account_entries_report.xml b/account_entries_report_analytic_plan/views/account_entries_report.xml new file mode 100644 index 00000000..20886b58 --- /dev/null +++ b/account_entries_report_analytic_plan/views/account_entries_report.xml @@ -0,0 +1,17 @@ + + + + + account.entries.report + + + + + + + + + + + +