← Back to team overview

c2c-oerpscenario team mailing list archive

[Bug 783123] Re: account chart - start and end period reversed

 

select id, date_start from account_period 
returns

 id | date_start 
----+------------
 10 | 2011-10-01
 11 | 2011-11-01
 12 | 2011-12-01
 13 | 2011-01-01
 16 | 2012-03-01
 17 | 2012-04-01
 18 | 2012-05-01
 19 | 2012-06-01
 20 | 2012-07-01
 21 | 2012-08-01
 22 | 2012-09-01
 23 | 2012-10-01
 24 | 2012-11-01
 25 | 2012-12-01
  1 | 2011-01-01
  2 | 2011-02-01
  3 | 2011-03-01
  4 | 2011-04-01
  5 | 2011-05-01
  6 | 2011-06-01
  7 | 2011-07-01
  8 | 2011-08-01
  9 | 2011-09-01
 14 | 2012-01-01
 15 | 2012-02-01
 26 | 2012-01-01


SELECT * FROM (SELECT p.id
                               FROM account_period p
                               LEFT JOIN account_fiscalyear f ON (p.fiscalyear_id = f.id)
                               WHERE f.id = 1
                               ORDER BY p.date_start ASC
                               LIMIT 1) AS period_start
                UNION ALL
                SELECT * FROM (SELECT p.id
                               FROM account_period p
                               LEFT JOIN account_fiscalyear f ON (p.fiscalyear_id = f.id)
                               WHERE f.id = 1
                               AND p.date_start < NOW()
                               ORDER BY p.date_stop DESC
                               LIMIT 1) AS period_stop;

returns
 id 
----
 13
  5
(2 rows)

-- 
You received this bug notification because you are a member of C2C
OERPScenario, which is subscribed to the OpenERP Project Group.
https://bugs.launchpad.net/bugs/783123

Title:
  account chart - start and end period reversed

Status in OpenERP Modules (addons):
  New

Bug description:
  after selectiong the fiscal year the start/end periods show up in the
  wrong fields

  obviously the UNION statement in
  account/wizard/account_chart.py
  does not guarantee a correct result, even the period id's are ascending
  IMHO these statements must be separated 

              cr.execute('''
                  SELECT * FROM (SELECT p.id
                                 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
                                 LIMIT 1) AS period_start
                  UNION
                  SELECT * FROM (SELECT p.id
                                 FROM account_period p
                                 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
                                 LIMIT 1) AS period_stop''', (fiscalyear_id, fiscalyear_id))


References