Merge lp:~therp-nl/account-financial-report/6.1-analytic_entries_report_fiscalyear into lp:~account-report-core-editor/account-financial-report/6.1
- 6.1-analytic_entries_report_fiscalyear
- Merge into 6.1
Status: | Needs review |
---|---|
Proposed branch: | lp:~therp-nl/account-financial-report/6.1-analytic_entries_report_fiscalyear |
Merge into: | lp:~account-report-core-editor/account-financial-report/6.1 |
Diff against target: |
420 lines (+377/-0) 7 files modified
analytic_entries_report_fiscalyear/__init__.py (+21/-0) analytic_entries_report_fiscalyear/__openerp__.py (+53/-0) analytic_entries_report_fiscalyear/i18n/analytic_entries_report_fiscalyear.pot (+48/-0) analytic_entries_report_fiscalyear/i18n/nl.po (+48/-0) analytic_entries_report_fiscalyear/model/__init__.py (+21/-0) analytic_entries_report_fiscalyear/model/analytic_entries_report.py (+132/-0) analytic_entries_report_fiscalyear/view/analytics_entry_report.xml (+54/-0) |
To merge this branch: | bzr merge lp:~therp-nl/account-financial-report/6.1-analytic_entries_report_fiscalyear |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Pedro Manuel Baeza | Needs Resubmitting | ||
Leonardo Pistone | code review | Approve | |
Review via email: mp+201968@code.launchpad.net |
Commit message
Description of the change
Leonardo Pistone (lepistone) wrote : | # |
- 27. By Holger Brunn (Therp)
-
[ADD] translation template + Dutch translation
[IMP] pass flake8
[ADD] docstring for read_group
[IMP] mention the original report being replaced by this one
Holger Brunn (Therp) (hbrunn) wrote : | # |
Thanks for your input Leonardo!
I took all your suggestions, but I don't understand your question about the query not being changed? It is the same, is there anything wrong with this?
Leonardo Pistone (lepistone) wrote : | # |
Nothing wrong Holger! I would appreciate just a little comment that says that the query is identical, to save time to people evaluating the module in the future.
I'm not blocking it though, thanks for your work!
- 28. By Holger Brunn (Therp)
-
[IMP] describe changes to original query
Pedro Manuel Baeza (pedro.baeza) wrote : | # |
This project is now hosted on https:/
Unmerged revisions
- 28. By Holger Brunn (Therp)
-
[IMP] describe changes to original query
- 27. By Holger Brunn (Therp)
-
[ADD] translation template + Dutch translation
[IMP] pass flake8
[ADD] docstring for read_group
[IMP] mention the original report being replaced by this one - 26. By Holger Brunn (Therp)
-
[ADD] module to report over analytic entries per fiscal period/year
Preview Diff
1 | === added directory 'analytic_entries_report_fiscalyear' |
2 | === added file 'analytic_entries_report_fiscalyear/__init__.py' |
3 | --- analytic_entries_report_fiscalyear/__init__.py 1970-01-01 00:00:00 +0000 |
4 | +++ analytic_entries_report_fiscalyear/__init__.py 2014-01-20 15:06:01 +0000 |
5 | @@ -0,0 +1,21 @@ |
6 | +# -*- coding: utf-8 -*- |
7 | +############################################################################## |
8 | +# |
9 | +# OpenERP, Open Source Management Solution |
10 | +# This module copyright (C) 2014 Therp BV (<http://therp.nl>). |
11 | +# |
12 | +# This program is free software: you can redistribute it and/or modify |
13 | +# it under the terms of the GNU Affero General Public License as |
14 | +# published by the Free Software Foundation, either version 3 of the |
15 | +# License, or (at your option) any later version. |
16 | +# |
17 | +# This program is distributed in the hope that it will be useful, |
18 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
19 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
20 | +# GNU Affero General Public License for more details. |
21 | +# |
22 | +# You should have received a copy of the GNU Affero General Public License |
23 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
24 | +# |
25 | +############################################################################## |
26 | +import model |
27 | |
28 | === added file 'analytic_entries_report_fiscalyear/__openerp__.py' |
29 | --- analytic_entries_report_fiscalyear/__openerp__.py 1970-01-01 00:00:00 +0000 |
30 | +++ analytic_entries_report_fiscalyear/__openerp__.py 2014-01-20 15:06:01 +0000 |
31 | @@ -0,0 +1,53 @@ |
32 | +# -*- coding: utf-8 -*- |
33 | +############################################################################## |
34 | +# |
35 | +# OpenERP, Open Source Management Solution |
36 | +# This module copyright (C) 2014 Therp BV (<http://therp.nl>). |
37 | +# |
38 | +# This program is free software: you can redistribute it and/or modify |
39 | +# it under the terms of the GNU Affero General Public License as |
40 | +# published by the Free Software Foundation, either version 3 of the |
41 | +# License, or (at your option) any later version. |
42 | +# |
43 | +# This program is distributed in the hope that it will be useful, |
44 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
45 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
46 | +# GNU Affero General Public License for more details. |
47 | +# |
48 | +# You should have received a copy of the GNU Affero General Public License |
49 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
50 | +# |
51 | +############################################################################## |
52 | +{ |
53 | + "name" : "Analytic Entries Statistics per fiscal period or year", |
54 | + "version" : "1.0", |
55 | + "author" : "Therp BV", |
56 | + "complexity": "easy", |
57 | + "description": """ |
58 | +Standard statistics over analytic entries don't allow grouping per fiscal year |
59 | +or period. This is partly because this concept doesn't fit analytic entries |
60 | +completely, as they don't necessarily are connected to a fiscal period. |
61 | + |
62 | +This addon overrides the standard analytic entries statistics to figure out the |
63 | +fiscal period based on the linked move line and falls back to the date if |
64 | +there's none. |
65 | + """, |
66 | + "category" : "Accounting & Finance", |
67 | + "depends" : [ |
68 | + 'account', |
69 | + ], |
70 | + "data" : [ |
71 | + "view/analytics_entry_report.xml", |
72 | + ], |
73 | + "js": [ |
74 | + ], |
75 | + "css": [ |
76 | + ], |
77 | + "qweb": [ |
78 | + ], |
79 | + "auto_install": False, |
80 | + "installable": True, |
81 | + "external_dependencies" : { |
82 | + 'python' : ['dateutil'], |
83 | + }, |
84 | +} |
85 | |
86 | === added directory 'analytic_entries_report_fiscalyear/i18n' |
87 | === added file 'analytic_entries_report_fiscalyear/i18n/analytic_entries_report_fiscalyear.pot' |
88 | --- analytic_entries_report_fiscalyear/i18n/analytic_entries_report_fiscalyear.pot 1970-01-01 00:00:00 +0000 |
89 | +++ analytic_entries_report_fiscalyear/i18n/analytic_entries_report_fiscalyear.pot 2014-01-20 15:06:01 +0000 |
90 | @@ -0,0 +1,48 @@ |
91 | +# Translation of OpenERP Server. |
92 | +# This file contains the translation of the following modules: |
93 | +# * analytic_entries_report_fiscalyear |
94 | +# |
95 | +msgid "" |
96 | +msgstr "" |
97 | +"Project-Id-Version: OpenERP Server 6.1\n" |
98 | +"Report-Msgid-Bugs-To: \n" |
99 | +"POT-Creation-Date: 2014-01-17 17:49+0000\n" |
100 | +"PO-Revision-Date: 2014-01-17 17:49+0000\n" |
101 | +"Last-Translator: <>\n" |
102 | +"Language-Team: \n" |
103 | +"MIME-Version: 1.0\n" |
104 | +"Content-Type: text/plain; charset=UTF-8\n" |
105 | +"Content-Transfer-Encoding: \n" |
106 | +"Plural-Forms: \n" |
107 | + |
108 | +#. module: analytic_entries_report_fiscalyear |
109 | +#: field:analytic.entries.report,period_id:0 |
110 | +msgid "Fiscal period" |
111 | +msgstr "" |
112 | + |
113 | +#. module: analytic_entries_report_fiscalyear |
114 | +#: view:analytic.entries.report:0 |
115 | +msgid "Period" |
116 | +msgstr "" |
117 | + |
118 | +#. module: analytic_entries_report_fiscalyear |
119 | +#: view:analytic.entries.report:0 |
120 | +msgid "Fiscal year-1" |
121 | +msgstr "" |
122 | + |
123 | +#. module: analytic_entries_report_fiscalyear |
124 | +#: view:analytic.entries.report:0 |
125 | +#: field:analytic.entries.report,fiscalyear_id:0 |
126 | +msgid "Fiscal year" |
127 | +msgstr "" |
128 | + |
129 | +#. module: analytic_entries_report_fiscalyear |
130 | +#: model:ir.model,name:analytic_entries_report_fiscalyear.model_analytic_entries_report |
131 | +msgid "Analytic Entries Statistics" |
132 | +msgstr "" |
133 | + |
134 | +#. module: analytic_entries_report_fiscalyear |
135 | +#: view:analytic.entries.report:0 |
136 | +msgid "Period-1" |
137 | +msgstr "" |
138 | + |
139 | |
140 | === added file 'analytic_entries_report_fiscalyear/i18n/nl.po' |
141 | --- analytic_entries_report_fiscalyear/i18n/nl.po 1970-01-01 00:00:00 +0000 |
142 | +++ analytic_entries_report_fiscalyear/i18n/nl.po 2014-01-20 15:06:01 +0000 |
143 | @@ -0,0 +1,48 @@ |
144 | +# Translation of OpenERP Server. |
145 | +# This file contains the translation of the following modules: |
146 | +# * analytic_entries_report_fiscalyear |
147 | +# |
148 | +msgid "" |
149 | +msgstr "" |
150 | +"Project-Id-Version: OpenERP Server 6.1\n" |
151 | +"Report-Msgid-Bugs-To: \n" |
152 | +"POT-Creation-Date: 2014-01-17 17:49+0000\n" |
153 | +"PO-Revision-Date: 2014-01-17 17:49+0000\n" |
154 | +"Last-Translator: <>\n" |
155 | +"Language-Team: \n" |
156 | +"MIME-Version: 1.0\n" |
157 | +"Content-Type: text/plain; charset=UTF-8\n" |
158 | +"Content-Transfer-Encoding: \n" |
159 | +"Plural-Forms: \n" |
160 | + |
161 | +#. module: analytic_entries_report_fiscalyear |
162 | +#: field:analytic.entries.report,period_id:0 |
163 | +msgid "Fiscal period" |
164 | +msgstr "Fiscale periode" |
165 | + |
166 | +#. module: analytic_entries_report_fiscalyear |
167 | +#: view:analytic.entries.report:0 |
168 | +msgid "Period" |
169 | +msgstr "Periode" |
170 | + |
171 | +#. module: analytic_entries_report_fiscalyear |
172 | +#: view:analytic.entries.report:0 |
173 | +msgid "Fiscal year-1" |
174 | +msgstr "Boekjaar-1" |
175 | + |
176 | +#. module: analytic_entries_report_fiscalyear |
177 | +#: view:analytic.entries.report:0 |
178 | +#: field:analytic.entries.report,fiscalyear_id:0 |
179 | +msgid "Fiscal year" |
180 | +msgstr "Boekjaar" |
181 | + |
182 | +#. module: analytic_entries_report_fiscalyear |
183 | +#: model:ir.model,name:analytic_entries_report_fiscalyear.model_analytic_entries_report |
184 | +msgid "Analytic Entries Statistics" |
185 | +msgstr "Kostenplaats boekingen analyses" |
186 | + |
187 | +#. module: analytic_entries_report_fiscalyear |
188 | +#: view:analytic.entries.report:0 |
189 | +msgid "Period-1" |
190 | +msgstr "Periode-1" |
191 | + |
192 | |
193 | === added directory 'analytic_entries_report_fiscalyear/model' |
194 | === added file 'analytic_entries_report_fiscalyear/model/__init__.py' |
195 | --- analytic_entries_report_fiscalyear/model/__init__.py 1970-01-01 00:00:00 +0000 |
196 | +++ analytic_entries_report_fiscalyear/model/__init__.py 2014-01-20 15:06:01 +0000 |
197 | @@ -0,0 +1,21 @@ |
198 | +# -*- coding: utf-8 -*- |
199 | +############################################################################## |
200 | +# |
201 | +# OpenERP, Open Source Management Solution |
202 | +# This module copyright (C) 2014 Therp BV (<http://therp.nl>). |
203 | +# |
204 | +# This program is free software: you can redistribute it and/or modify |
205 | +# it under the terms of the GNU Affero General Public License as |
206 | +# published by the Free Software Foundation, either version 3 of the |
207 | +# License, or (at your option) any later version. |
208 | +# |
209 | +# This program is distributed in the hope that it will be useful, |
210 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
211 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
212 | +# GNU Affero General Public License for more details. |
213 | +# |
214 | +# You should have received a copy of the GNU Affero General Public License |
215 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
216 | +# |
217 | +############################################################################## |
218 | +import analytic_entries_report |
219 | |
220 | === added file 'analytic_entries_report_fiscalyear/model/analytic_entries_report.py' |
221 | --- analytic_entries_report_fiscalyear/model/analytic_entries_report.py 1970-01-01 00:00:00 +0000 |
222 | +++ analytic_entries_report_fiscalyear/model/analytic_entries_report.py 2014-01-20 15:06:01 +0000 |
223 | @@ -0,0 +1,132 @@ |
224 | +# -*- coding: utf-8 -*- |
225 | +############################################################################## |
226 | +# |
227 | +# OpenERP, Open Source Management Solution |
228 | +# This module copyright (C) 2014 Therp BV (<http://therp.nl>). |
229 | +# |
230 | +# This program is free software: you can redistribute it and/or modify |
231 | +# it under the terms of the GNU Affero General Public License as |
232 | +# published by the Free Software Foundation, either version 3 of the |
233 | +# License, or (at your option) any later version. |
234 | +# |
235 | +# This program is distributed in the hope that it will be useful, |
236 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
237 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
238 | +# GNU Affero General Public License for more details. |
239 | +# |
240 | +# You should have received a copy of the GNU Affero General Public License |
241 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
242 | +# |
243 | +############################################################################## |
244 | +import datetime |
245 | +from dateutil.relativedelta import relativedelta |
246 | +from openerp.osv.orm import Model |
247 | +from openerp.osv import fields |
248 | + |
249 | + |
250 | +class AnalyticEntriesReport(Model): |
251 | + _inherit = 'analytic.entries.report' |
252 | + |
253 | + _columns = { |
254 | + 'fiscalyear_id': fields.many2one( |
255 | + 'account.fiscalyear', 'Fiscal year'), |
256 | + 'period_id': fields.many2one( |
257 | + 'account.period', 'Fiscal period'), |
258 | + } |
259 | + |
260 | + def init(self, cr): |
261 | + #mutatis mutandis the same query as in |
262 | + #account_analytic_entries_report.py |
263 | + #added joins to account_period & account_move_line |
264 | + #added appropriate fields to select list and group by |
265 | + cr.execute(""" |
266 | + create or replace view analytic_entries_report as ( |
267 | + select |
268 | + min(a.id) as id, |
269 | + count(distinct a.id) as nbr, |
270 | + a.date as date, |
271 | + to_char(a.date, 'YYYY') as year, |
272 | + to_char(a.date, 'MM') as month, |
273 | + to_char(a.date, 'YYYY-MM-DD') as day, |
274 | + a.user_id as user_id, |
275 | + a.name as name, |
276 | + analytic.partner_id as partner_id, |
277 | + a.company_id as company_id, |
278 | + a.currency_id as currency_id, |
279 | + a.account_id as account_id, |
280 | + a.general_account_id as general_account_id, |
281 | + a.journal_id as journal_id, |
282 | + a.move_id as move_id, |
283 | + a.product_id as product_id, |
284 | + a.product_uom_id as product_uom_id, |
285 | + sum(a.amount) as amount, |
286 | + sum(a.unit_amount) as unit_amount, |
287 | + coalesce(ml.period_id, p.id) as period_id, |
288 | + coalesce(p_from_move.fiscalyear_id, p.fiscalyear_id) |
289 | + as fiscalyear_id |
290 | + |
291 | + from |
292 | + account_analytic_line a |
293 | + join account_analytic_account analytic |
294 | + on analytic.id = a.account_id |
295 | + left outer join account_period p |
296 | + on p.special = False and p.date_start <= a.date |
297 | + and p.date_stop >= a.date |
298 | + left outer join account_move_line ml |
299 | + on a.move_id = ml.id |
300 | + left outer join account_period p_from_move |
301 | + on ml.period_id = p_from_move.id |
302 | + |
303 | + group by |
304 | + a.date, |
305 | + coalesce(p_from_move.fiscalyear_id, p.fiscalyear_id), |
306 | + coalesce(ml.period_id, p.id), a.user_id,a.name, |
307 | + analytic.partner_id,a.company_id, a.currency_id, |
308 | + a.account_id,a.general_account_id,a.journal_id, |
309 | + a.move_id,a.product_id,a.product_uom_id |
310 | + ) |
311 | + """) |
312 | + |
313 | + def read_group(self, cr, uid, domain, fields, groupby, offset=0, |
314 | + limit=None, context=None, orderby=False): |
315 | + '''Override read_group to respect filters whose domain can't be |
316 | + computed on the client side''' |
317 | + |
318 | + if context is None: |
319 | + context = {} |
320 | + |
321 | + if 'filter_fiscalyear' in context: |
322 | + date = datetime.date.today() + relativedelta( |
323 | + years=context['filter_fiscalyear']) |
324 | + fiscalyear_id = self.pool.get('account.fiscalyear').find( |
325 | + cr, uid, dt=date, context=context) |
326 | + domain.append(('fiscalyear_id', '=', fiscalyear_id)) |
327 | + |
328 | + if 'filter_period' in context: |
329 | + account_period = self.pool.get('account.period') |
330 | + period_ids = account_period.find( |
331 | + cr, uid, |
332 | + context=dict(context, account_period_prefer_normal=True)) |
333 | + current_period = account_period.browse( |
334 | + cr, uid, period_ids[0], context=context) |
335 | + |
336 | + direction = '>=' |
337 | + if context['filter_period'] < 0: |
338 | + direction = '<=' |
339 | + |
340 | + period_ids = account_period.search( |
341 | + cr, uid, |
342 | + [ |
343 | + ('date_start', direction, current_period.date_start), |
344 | + ('special', '=', False), |
345 | + ], |
346 | + limit=(abs(context['filter_period']) + 1) or 1, |
347 | + order='date_start ' + ('asc' if direction == '>=' else 'desc'), |
348 | + context=context) |
349 | + |
350 | + domain.append( |
351 | + ('period_id', '=', period_ids[context['filter_period']])) |
352 | + |
353 | + return super(AnalyticEntriesReport, self).read_group( |
354 | + cr, uid, domain, fields, groupby, |
355 | + offset=offset, limit=limit, context=context, orderby=orderby) |
356 | |
357 | === added directory 'analytic_entries_report_fiscalyear/static' |
358 | === added directory 'analytic_entries_report_fiscalyear/static/src' |
359 | === added directory 'analytic_entries_report_fiscalyear/static/src/img' |
360 | === added file 'analytic_entries_report_fiscalyear/static/src/img/icon.png' |
361 | 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-20 15:06:01 +0000 differ |
362 | === added directory 'analytic_entries_report_fiscalyear/view' |
363 | === added file 'analytic_entries_report_fiscalyear/view/analytics_entry_report.xml' |
364 | --- analytic_entries_report_fiscalyear/view/analytics_entry_report.xml 1970-01-01 00:00:00 +0000 |
365 | +++ analytic_entries_report_fiscalyear/view/analytics_entry_report.xml 2014-01-20 15:06:01 +0000 |
366 | @@ -0,0 +1,54 @@ |
367 | +<?xml version="1.0" encoding="UTF-8"?> |
368 | +<openerp> |
369 | + <data> |
370 | + <record id="view_analytic_entries_report_tree" model="ir.ui.view"> |
371 | + <field name="model">analytic.entries.report</field> |
372 | + <field name="type">tree</field> |
373 | + <field name="inherit_id" ref="account.view_analytic_entries_report_tree" /> |
374 | + <field name="arch" type="xml"> |
375 | + <data> |
376 | + <field name="product_uom_id" position="after"> |
377 | + <field name="period_id" invisible="1" /> |
378 | + <field name="fiscalyear_id" invisible="1" /> |
379 | + </field> |
380 | + </data> |
381 | + </field> |
382 | + </record> |
383 | + <record id="view_analytic_entries_report_search" model="ir.ui.view"> |
384 | + <field name="model">analytic.entries.report</field> |
385 | + <field name="type">search</field> |
386 | + <field name="inherit_id" ref="account.view_analytic_entries_report_search" /> |
387 | + <field name="arch" type="xml"> |
388 | + <data> |
389 | + <filter name="year" position="before"> |
390 | + <filter icon="terp-go-year" string="Fiscal year" |
391 | + name="filter_fiscalyear" |
392 | + context="{'filter_fiscalyear': 0}" /> |
393 | + <filter icon="terp-go-year" string="Fiscal year-1" |
394 | + name="filter_fiscalyear-1" |
395 | + context="{'filter_fiscalyear': -1}" /> |
396 | + <filter icon="terp-go-month" string="Period" |
397 | + name="filter_period" |
398 | + context="{'filter_period': 0}" /> |
399 | + <filter icon="terp-go-month" string="Period-1" |
400 | + name="filter_period-1" |
401 | + context="{'filter_period': -1}" /> |
402 | + <separator orientation="vertical" /> |
403 | + </filter> |
404 | + <filter context="{'group_by':'day'}" position="before"> |
405 | + <filter icon="terp-go-year" string="Fiscal year" |
406 | + name="group_fiscalyear" |
407 | + context="{'group_by':'fiscalyear_id'}" /> |
408 | + <filter icon="terp-go-month" string="Period" |
409 | + name="group_period" |
410 | + context="{'group_by':'period_id'}" /> |
411 | + <separator orientation="vertical" /> |
412 | + </filter> |
413 | + </data> |
414 | + </field> |
415 | + </record> |
416 | + <record id="account.action_analytic_entries_report" model="ir.actions.act_window"> |
417 | + <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> |
418 | + </record> |
419 | + </data> |
420 | +</openerp> |
Holger,
It looks good, with a few small remarks:
* I would expand further the description in __openerp__.py, stating explicitly that we are overriding the existing report from the account module. Furthermore: apart from the period, the query is the same as the account module? Maybe a link to the bug?
* read_group could benefit from a docstring to explain what is going on.
* flake8 shows some issues, like spaces before colons and eigth-space indentation.
Thanks for your work