← Back to team overview

credativ team mailing list archive

[Merge] lp:~credativ/openobject-addons/6.1-fix-lp1190773 into lp:~credativ/openobject-addons/6.1

 

Kinner Vachhani has proposed merging lp:~credativ/openobject-addons/6.1-fix-lp1190773 into lp:~credativ/openobject-addons/6.1.

Requested reviews:
  credativ (credativ)
Related bugs:
  Bug #1190773 in credativ-openerp: "Chart of accounts - fiscal year periods are not sorted properly"
  https://bugs.launchpad.net/credativ-openerp/+bug/1190773

For more details, see:
https://code.launchpad.net/~credativ/openobject-addons/6.1-fix-lp1190773/+merge/169452

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.
-- 
https://code.launchpad.net/~credativ/openobject-addons/6.1-fix-lp1190773/+merge/169452
Your team credativ is requested to review the proposed merge of lp:~credativ/openobject-addons/6.1-fix-lp1190773 into lp:~credativ/openobject-addons/6.1.
=== 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:39:32 +0000
@@ -51,7 +51,7 @@
                                FROM account_period p
                                LEFT JOIN account_fiscalyear f ON (p.fiscalyear_id = f.id)
                                WHERE f.id = %s
-                               ORDER BY p.date_start ASC
+                               ORDER BY p.date_start ASC, p.special DESC
                                LIMIT 1) AS period_start
                 UNION ALL
                 SELECT * FROM (SELECT p.id
@@ -59,7 +59,7 @@
                                LEFT JOIN account_fiscalyear f ON (p.fiscalyear_id = f.id)
                                WHERE f.id = %s
                                AND p.date_start < NOW()
-                               ORDER BY p.date_stop DESC
+                               ORDER BY p.date_stop DESC, p.special DESC
                                LIMIT 1) AS period_stop''', (fiscalyear_id, fiscalyear_id))
             periods =  [i[0] for i in cr.fetchall()]
             if periods and len(periods) > 1:


Follow ups