← Back to team overview

credativ team mailing list archive

[Merge] lp:~credativ/openobject-addons/7.0-fix-1190773 into lp:openobject-addons/7.0

 

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

Requested reviews:
  OpenERP Core Team (openerp)

For more details, see:
https://code.launchpad.net/~credativ/openobject-addons/7.0-fix-1190773/+merge/169460

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/7.0-fix-1190773/+merge/169460
Your team credativ is subscribed to branch lp:~credativ/openobject-addons/7.0-fix-1190773.
=== modified file 'account/wizard/account_chart.py'
--- account/wizard/account_chart.py	2012-12-06 14:56:32 +0000
+++ account/wizard/account_chart.py	2013-06-14 15:04:28 +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: