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
=== modified file 'account/wizard/account_chart.py'
--- account/wizard/account_chart.py 2011-10-27 21:11:24 +0000
+++ account/wizard/account_chart.py 2013-06-14 14:12:42 +0000
@@ -51,7 +51,7 @@
51 FROM account_period p51 FROM account_period p
52 LEFT JOIN account_fiscalyear f ON (p.fiscalyear_id = f.id)52 LEFT JOIN account_fiscalyear f ON (p.fiscalyear_id = f.id)
53 WHERE f.id = %s53 WHERE f.id = %s
54 ORDER BY p.date_start ASC54 ORDER BY p.date_start ASC, p.special DESC
55 LIMIT 1) AS period_start55 LIMIT 1) AS period_start
56 UNION ALL56 UNION ALL
57 SELECT * FROM (SELECT p.id57 SELECT * FROM (SELECT p.id
@@ -59,7 +59,7 @@
59 LEFT JOIN account_fiscalyear f ON (p.fiscalyear_id = f.id)59 LEFT JOIN account_fiscalyear f ON (p.fiscalyear_id = f.id)
60 WHERE f.id = %s60 WHERE f.id = %s
61 AND p.date_start < NOW()61 AND p.date_start < NOW()
62 ORDER BY p.date_stop DESC62 ORDER BY p.date_stop DESC, p.special DESC
63 LIMIT 1) AS period_stop''', (fiscalyear_id, fiscalyear_id))63 LIMIT 1) AS period_stop''', (fiscalyear_id, fiscalyear_id))
64 periods = [i[0] for i in cr.fetchall()]64 periods = [i[0] for i in cr.fetchall()]
65 if periods and len(periods) > 1:65 if periods and len(periods) > 1: