Browse Source

[ADD] account_entries_report_analytic_plan

pull/223/head
Holger Brunn 8 years ago
parent
commit
9802ac5a7d
No known key found for this signature in database GPG Key ID: 1C9760FECA3AE18
  1. 62
      account_entries_report_analytic_plan/README.rst
  2. 4
      account_entries_report_analytic_plan/__init__.py
  3. 22
      account_entries_report_analytic_plan/__openerp__.py
  4. 28
      account_entries_report_analytic_plan/i18n/nl.po
  5. 4
      account_entries_report_analytic_plan/models/__init__.py
  6. 33
      account_entries_report_analytic_plan/models/account_entries_report.py
  7. BIN
      account_entries_report_analytic_plan/static/description/icon.png
  8. 17
      account_entries_report_analytic_plan/views/account_entries_report.xml

62
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
<https://github.com/OCA/account-financial-reporting/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 <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.
Contributors
------------
* Holger Brunn <hbrunn@therp.nl>
Do not contact contributors directly about help with questions or problems concerning this addon, but use the `community mailing list <mailto:community@mail.odoo.com>`_ or the `appropriate specialized mailinglist <https://odoo-community.org/groups>`_ 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.

4
account_entries_report_analytic_plan/__init__.py

@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# © 2016 Therp BV <http://therp.nl>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import models

22
account_entries_report_analytic_plan/__openerp__.py

@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
# © 2016 Therp BV <http://therp.nl>
# 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',
],
},
}

28
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"

4
account_entries_report_analytic_plan/models/__init__.py

@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# © 2016 Therp BV <http://therp.nl>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import account_entries_report

33
account_entries_report_analytic_plan/models/account_entries_report.py

@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
# © 2016 Therp BV <http://therp.nl>
# 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])))

BIN
account_entries_report_analytic_plan/static/description/icon.png

After

Width: 128  |  Height: 128  |  Size: 9.2 KiB

17
account_entries_report_analytic_plan/views/account_entries_report.xml

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<record id="view_account_entries_report_search" model="ir.ui.view">
<field name="model">account.entries.report</field>
<field name="inherit_id" ref="account.view_account_entries_report_search" />
<field name="arch" type="xml">
<field name="company_id" position="after">
<field name="analytics_id" />
</field>
<filter name="group_journal" position="before">
<filter name="group_analytics" string="Analytic Distribution" context="{'group_by': 'analytics_id'}" />
</filter>
</field>
</record>
</data>
</openerp>
Loading…
Cancel
Save