openerp-community-reviewer team mailing list archive
-
openerp-community-reviewer team
-
Mailing list archive
-
Message #02947
lp:~therp-nl/account-financial-report/6.1-analytic_entries_report_fiscalyear into lp:account-financial-report/6.1
Holger Brunn (Therp) has proposed merging lp:~therp-nl/account-financial-report/6.1-analytic_entries_report_fiscalyear into lp:account-financial-report/6.1.
Requested reviews:
Account Report Core Editors (account-report-core-editor)
Related bugs:
Bug #987038 in OpenERP Addons: "Analytic Entries Analysis must group by fiscal year"
https://bugs.launchpad.net/openobject-addons/+bug/987038
For more details, see:
https://code.launchpad.net/~therp-nl/account-financial-report/6.1-analytic_entries_report_fiscalyear/+merge/201968
--
https://code.launchpad.net/~therp-nl/account-financial-report/6.1-analytic_entries_report_fiscalyear/+merge/201968
Your team Account Report Core Editors is requested to review the proposed merge of lp:~therp-nl/account-financial-report/6.1-analytic_entries_report_fiscalyear into lp:account-financial-report/6.1.
=== added directory 'analytic_entries_report_fiscalyear'
=== added file 'analytic_entries_report_fiscalyear/__init__.py'
--- analytic_entries_report_fiscalyear/__init__.py 1970-01-01 00:00:00 +0000
+++ analytic_entries_report_fiscalyear/__init__.py 2014-01-16 17:07:13 +0000
@@ -0,0 +1,21 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# This module copyright (C) 2014 Therp BV (<http://therp.nl>).
+#
+# 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 model
=== added file 'analytic_entries_report_fiscalyear/__openerp__.py'
--- analytic_entries_report_fiscalyear/__openerp__.py 1970-01-01 00:00:00 +0000
+++ analytic_entries_report_fiscalyear/__openerp__.py 2014-01-16 17:07:13 +0000
@@ -0,0 +1,52 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# This module copyright (C) 2014 Therp BV (<http://therp.nl>).
+#
+# 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" : "Analytic Entries Statistics per fiscal period or year",
+ "version" : "1.0",
+ "author" : "Therp BV",
+ "complexity": "easy",
+ "description": """
+Standard statistics over analytic entries don't allow grouping per fiscal year
+or period. This is partly because this concept doesn't fit analytic entries
+completely, as they don't necessarily are connected to a fiscal period.
+
+This addons figures out the fiscal period based on the linked move line and
+falls back to the date when there's none.
+ """,
+ "category" : "Accounting & Finance",
+ "depends" : [
+ 'account',
+ ],
+ "data" : [
+ "view/analytics_entry_report.xml",
+ ],
+ "js": [
+ ],
+ "css": [
+ ],
+ "qweb": [
+ ],
+ "auto_install": False,
+ "installable": True,
+ "external_dependencies" : {
+ 'python' : ['dateutil'],
+ },
+}
=== added directory 'analytic_entries_report_fiscalyear/model'
=== added file 'analytic_entries_report_fiscalyear/model/__init__.py'
--- analytic_entries_report_fiscalyear/model/__init__.py 1970-01-01 00:00:00 +0000
+++ analytic_entries_report_fiscalyear/model/__init__.py 2014-01-16 17:07:13 +0000
@@ -0,0 +1,21 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# This module copyright (C) 2014 Therp BV (<http://therp.nl>).
+#
+# 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 analytic_entries_report
=== added file 'analytic_entries_report_fiscalyear/model/analytic_entries_report.py'
--- analytic_entries_report_fiscalyear/model/analytic_entries_report.py 1970-01-01 00:00:00 +0000
+++ analytic_entries_report_fiscalyear/model/analytic_entries_report.py 2014-01-16 17:07:13 +0000
@@ -0,0 +1,125 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# This module copyright (C) 2014 Therp BV (<http://therp.nl>).
+#
+# 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 datetime
+from dateutil.relativedelta import relativedelta
+from openerp.osv.orm import Model
+from openerp.osv import fields
+
+class AnalyticEntriesReport(Model):
+ _inherit = 'analytic.entries.report'
+
+ _columns = {
+ 'fiscalyear_id': fields.many2one(
+ 'account.fiscalyear', 'Fiscal year'),
+ 'period_id': fields.many2one(
+ 'account.period', 'Fiscal period'),
+ }
+
+ def init(self, cr):
+ cr.execute("""
+ create or replace view analytic_entries_report as (
+ select
+ min(a.id) as id,
+ count(distinct a.id) as nbr,
+ a.date as date,
+ to_char(a.date, 'YYYY') as year,
+ to_char(a.date, 'MM') as month,
+ to_char(a.date, 'YYYY-MM-DD') as day,
+ a.user_id as user_id,
+ a.name as name,
+ analytic.partner_id as partner_id,
+ a.company_id as company_id,
+ a.currency_id as currency_id,
+ a.account_id as account_id,
+ a.general_account_id as general_account_id,
+ a.journal_id as journal_id,
+ a.move_id as move_id,
+ a.product_id as product_id,
+ a.product_uom_id as product_uom_id,
+ sum(a.amount) as amount,
+ sum(a.unit_amount) as unit_amount,
+ coalesce(ml.period_id, p.id) as period_id,
+ coalesce(p_from_move.fiscalyear_id, p.fiscalyear_id)
+ as fiscalyear_id
+
+ from
+ account_analytic_line a
+ join account_analytic_account analytic
+ on analytic.id = a.account_id
+ left outer join account_period p
+ on p.special = False and p.date_start <= a.date
+ and p.date_stop >= a.date
+ left outer join account_move_line ml
+ on a.move_id = ml.id
+ left outer join account_period p_from_move
+ on ml.period_id = p_from_move.id
+
+ group by
+ a.date,
+ coalesce(p_from_move.fiscalyear_id, p.fiscalyear_id),
+ coalesce(ml.period_id, p.id), a.user_id,a.name,
+ analytic.partner_id,a.company_id, a.currency_id,
+ a.account_id,a.general_account_id,a.journal_id,
+ a.move_id,a.product_id,a.product_uom_id
+ )
+ """)
+
+ def read_group(self, cr, uid, domain, fields, groupby, offset=0,
+ limit=None, context=None, orderby=False):
+ if context is None:
+ context = {}
+
+ if 'filter_fiscalyear' in context:
+ date = datetime.date.today() + relativedelta(
+ years=context['filter_fiscalyear'])
+ fiscalyear_id = self.pool.get('account.fiscalyear').find(
+ cr, uid, dt=date, context=context)
+ domain.append(('fiscalyear_id', '=', fiscalyear_id))
+
+ if 'filter_period' in context:
+ account_period = self.pool.get('account.period')
+ period_ids = account_period.find(
+ cr, uid,
+ context=dict(context, account_period_prefer_normal=True))
+ current_period = account_period.browse(
+ cr, uid, period_ids[0], context=context)
+
+ direction = '>='
+ if context['filter_period'] < 0:
+ direction = '<='
+
+ period_ids = account_period.search(
+ cr, uid,
+ [
+ ('date_start', direction, current_period.date_start),
+ ('special', '=', False),
+ ],
+ limit=(abs(context['filter_period']) + 1) or 1,
+ order='date_start ' +
+ ('asc' if direction == '>=' else 'desc'),
+ context=context)
+
+ domain.append(
+ ('period_id', '=', period_ids[context['filter_period']]))
+
+ return super(AnalyticEntriesReport, self).read_group(
+ cr, uid, domain, fields, groupby,
+ offset=offset, limit=limit, context=context, orderby=orderby)
=== added directory 'analytic_entries_report_fiscalyear/static'
=== added directory 'analytic_entries_report_fiscalyear/static/src'
=== added directory 'analytic_entries_report_fiscalyear/static/src/img'
=== added file 'analytic_entries_report_fiscalyear/static/src/img/icon.png'
Binary files analytic_entries_report_fiscalyear/static/src/img/icon.png 1970-01-01 00:00:00 +0000 and analytic_entries_report_fiscalyear/static/src/img/icon.png 2014-01-16 17:07:13 +0000 differ
=== added directory 'analytic_entries_report_fiscalyear/view'
=== added file 'analytic_entries_report_fiscalyear/view/analytics_entry_report.xml'
--- analytic_entries_report_fiscalyear/view/analytics_entry_report.xml 1970-01-01 00:00:00 +0000
+++ analytic_entries_report_fiscalyear/view/analytics_entry_report.xml 2014-01-16 17:07:13 +0000
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+ <data>
+ <record id="view_analytic_entries_report_tree" model="ir.ui.view">
+ <field name="model">analytic.entries.report</field>
+ <field name="type">tree</field>
+ <field name="inherit_id" ref="account.view_analytic_entries_report_tree" />
+ <field name="arch" type="xml">
+ <data>
+ <field name="product_uom_id" position="after">
+ <field name="period_id" invisible="1" />
+ <field name="fiscalyear_id" invisible="1" />
+ </field>
+ </data>
+ </field>
+ </record>
+ <record id="view_analytic_entries_report_search" model="ir.ui.view">
+ <field name="model">analytic.entries.report</field>
+ <field name="type">search</field>
+ <field name="inherit_id" ref="account.view_analytic_entries_report_search" />
+ <field name="arch" type="xml">
+ <data>
+ <filter name="year" position="before">
+ <filter icon="terp-go-year" string="Fiscal year"
+ name="filter_fiscalyear"
+ context="{'filter_fiscalyear': 0}" />
+ <filter icon="terp-go-year" string="Fiscal year-1"
+ name="filter_fiscalyear-1"
+ context="{'filter_fiscalyear': -1}" />
+ <filter icon="terp-go-month" string="Period"
+ name="filter_period"
+ context="{'filter_period': 0}" />
+ <filter icon="terp-go-month" string="Period-1"
+ name="filter_period-1"
+ context="{'filter_period': -1}" />
+ <separator orientation="vertical" />
+ </filter>
+ <filter context="{'group_by':'day'}" position="before">
+ <filter icon="terp-go-year" string="Fiscal year"
+ name="group_fiscalyear"
+ context="{'group_by':'fiscalyear_id'}" />
+ <filter icon="terp-go-month" string="Period"
+ name="group_period"
+ context="{'group_by':'period_id'}" />
+ <separator orientation="vertical" />
+ </filter>
+ </data>
+ </field>
+ </record>
+ <record id="account.action_analytic_entries_report" model="ir.actions.act_window">
+ <field name="context">{'search_default_filter_fiscalyear':1,'search_default_filter_period':1, 'group_by_no_leaf':1, 'search_default_Account':1, 'group_by':[]}</field>
+ </record>
+ </data>
+</openerp>
Follow ups