← Back to team overview

openerp-india team mailing list archive

[Bug 951722] [NEW] [account] account.move.line _query_get method should not return all periods when period.start_date = fiscalyear.start_date AND context= {'fiscalyear':integer, 'periods':[only_integer], 'initial_bal':True}

 

Public bug reported:

account.move.line _query_get method should not return all periods when
period.start_date = fiscalyear.start_date AND context=
{'fiscalyear':integer, 'periods':[only_integer], 'initial_bal':True}

When passing context like this 
ctx = {'fiscalyear':integer, 'periods':[integer], 'initial_bal':True}

and ctx['periods'] is a list of only one integer, being that integer the first period
of the given ctx['fiscalyear'], 

_query_get in account.move.line returns

QUERY  l.state <> 'draft' AND l.period_id IN (SELECT id FROM
account_period WHERE fiscalyear_id IN (1))

Which is wrong, For a fiscalyear in the first period 
the initial-balance is not the whole year

a) I would approach this way

I think that line 86 instead of:

periods = fiscalperiod_obj.search(cr, uid, [('date_start', '<',
first_period.date_start)])

should be:

periods = fiscalperiod_obj.search(cr, uid, [('date_start', '<',
first_period.date_start),('fiscalyear_id','in',fiscalyear_ids)])

because those periods should not be out of the fiscalyear_ids being
asked

b) Given that there are special periods that could overlap in the same
date:

NAME----------START----------END------------FY------SPECIAL
AP/2012-------01/01/2012-----01-01-2012-----2012----True
01/2012-------01/01/2012-----01-31-2012-----2012----False
02/2012-------02/01/2012-----01-28-2012-----2012----False
03/2012-------03/01/2012-----03-31-2012-----2012----False

AP/2012 holds the opening entries
quote line 24 "... because the best practice is to 
generate the FY opening entries", and
01/2012 holds regular accounting transactions.

if 
ctx = {'fiscalyear':2012, 'periods':[01/2012], 'initial_bal':True}
is passed line 86 will return [] withoud taking account AP/2012

there should be a else clause

if not periods:
    #~ Looking for special periods at the beginning of FY
    periods = fiscalperiod_obj.search(cr, uid, [('date_start', '>=', first_period.date_start),('date_stop', '<=', first_period.date_stop),('fiscalyear_id','in',fiscalyear_ids),('special','=',True)])


and finally if all fails not periods at all, 
there should be a else clause where:

query = False

That should not return a thing

** Affects: openobject-addons
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of OpenERP
Indian Team, which is subscribed to OpenERP Addons.
https://bugs.launchpad.net/bugs/951722

Title:
  [account] account.move.line _query_get method should not return all
  periods when period.start_date = fiscalyear.start_date AND context=
  {'fiscalyear':integer, 'periods':[only_integer], 'initial_bal':True}

Status in OpenERP Addons (modules):
  New

Bug description:
  account.move.line _query_get method should not return all periods when
  period.start_date = fiscalyear.start_date AND context=
  {'fiscalyear':integer, 'periods':[only_integer], 'initial_bal':True}

  When passing context like this 
  ctx = {'fiscalyear':integer, 'periods':[integer], 'initial_bal':True}

  and ctx['periods'] is a list of only one integer, being that integer the first period
  of the given ctx['fiscalyear'], 

  _query_get in account.move.line returns

  QUERY  l.state <> 'draft' AND l.period_id IN (SELECT id FROM
  account_period WHERE fiscalyear_id IN (1))

  Which is wrong, For a fiscalyear in the first period 
  the initial-balance is not the whole year

  a) I would approach this way

  I think that line 86 instead of:

  periods = fiscalperiod_obj.search(cr, uid, [('date_start', '<',
  first_period.date_start)])

  should be:

  periods = fiscalperiod_obj.search(cr, uid, [('date_start', '<',
  first_period.date_start),('fiscalyear_id','in',fiscalyear_ids)])

  because those periods should not be out of the fiscalyear_ids being
  asked

  b) Given that there are special periods that could overlap in the same
  date:

  NAME----------START----------END------------FY------SPECIAL
  AP/2012-------01/01/2012-----01-01-2012-----2012----True
  01/2012-------01/01/2012-----01-31-2012-----2012----False
  02/2012-------02/01/2012-----01-28-2012-----2012----False
  03/2012-------03/01/2012-----03-31-2012-----2012----False

  AP/2012 holds the opening entries
  quote line 24 "... because the best practice is to 
  generate the FY opening entries", and
  01/2012 holds regular accounting transactions.

  if 
  ctx = {'fiscalyear':2012, 'periods':[01/2012], 'initial_bal':True}
  is passed line 86 will return [] withoud taking account AP/2012

  there should be a else clause

  if not periods:
      #~ Looking for special periods at the beginning of FY
      periods = fiscalperiod_obj.search(cr, uid, [('date_start', '>=', first_period.date_start),('date_stop', '<=', first_period.date_stop),('fiscalyear_id','in',fiscalyear_ids),('special','=',True)])

  
  and finally if all fails not periods at all, 
  there should be a else clause where:

  query = False

  That should not return a thing

To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-addons/+bug/951722/+subscriptions


Follow ups

References