Merge lp:~kinner-vachhani/openobject-addons/6.1-fiscal-year-periods-sorting-fix into lp:openobject-addons/6.1

Proposed by Kinner Vachhani
Status: Needs review
Proposed branch: lp:~kinner-vachhani/openobject-addons/6.1-fiscal-year-periods-sorting-fix
Merge into: lp:openobject-addons/6.1
Diff against target: 21 lines (+2/-2)
1 file modified
account/wizard/account_chart.py (+2/-2)
To merge this branch: bzr merge lp:~kinner-vachhani/openobject-addons/6.1-fiscal-year-periods-sorting-fix
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+169443@code.launchpad.net

Description of the change

Account period is sorted on ID and not opening period.

The code in onchange handler for fiscalyear in wizard/account_chart.py sort period based on start and end date regardless of special period.

Code module sorting code:
ORDER BY p.date_start ASC
ORDER BY p.date_stop DESC

This causes a bug in the situation where the opening period has a higher ID than the first normal period in the year

Steps to produce bug:
* Create a new fiscalyear
* Open the chart of accounts wizard and verify that the opening period is shown as first period
* Remove the opening period
* Create a new opening period (date_start is first day of the year, special=true)
* Open the chart of accounts wizard
* The first period shown is no longer the opening period

The resulting chart of accounts is incorrect because opening balances are not shown.

To post a comment you must log in.

Unmerged revisions

7221. By Kinner Vachhani

[Fix] fiscal year periods are not sorted properly

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account/wizard/account_chart.py'
2--- account/wizard/account_chart.py 2011-10-27 21:11:24 +0000
3+++ account/wizard/account_chart.py 2013-06-14 14:12:42 +0000
4@@ -51,7 +51,7 @@
5 FROM account_period p
6 LEFT JOIN account_fiscalyear f ON (p.fiscalyear_id = f.id)
7 WHERE f.id = %s
8- ORDER BY p.date_start ASC
9+ ORDER BY p.date_start ASC, p.special DESC
10 LIMIT 1) AS period_start
11 UNION ALL
12 SELECT * FROM (SELECT p.id
13@@ -59,7 +59,7 @@
14 LEFT JOIN account_fiscalyear f ON (p.fiscalyear_id = f.id)
15 WHERE f.id = %s
16 AND p.date_start < NOW()
17- ORDER BY p.date_stop DESC
18+ ORDER BY p.date_stop DESC, p.special DESC
19 LIMIT 1) AS period_stop''', (fiscalyear_id, fiscalyear_id))
20 periods = [i[0] for i in cr.fetchall()]
21 if periods and len(periods) > 1: