[FIX] account: typo in query_get + fix in common wizard report + [REF] account: query_get removal of period_manner in context

bzr revid: qdp-launchpad@tinyerp.com-20101001152403-7yy1l7sy0kdq728l
This commit is contained in:
qdp-launchpad@tinyerp.com 2010-10-01 17:24:03 +02:00
parent 574e967cc2
commit d9c2e1a2e8
2 changed files with 3 additions and 38 deletions

View File

@ -56,7 +56,7 @@ class account_move_line(osv.osv):
where_move_lines_by_date = ''
if context.get('date_from', False) and context.get('date_to', False):
if initital_bal:
if initial_bal:
where_move_lines_by_date = " AND " +obj+".move_id in ( select id from account_move where date < '"+context['date_from']+"')"
else:
where_move_lines_by_date = " AND " +obj+".move_id in ( select id from account_move where date >= '" +context['date_from']+"' AND date <= '"+context['date_to']+"')"
@ -88,42 +88,6 @@ class account_move_line(osv.osv):
query += company_clause
if context.get('period_manner','') == 'created':
#the query have to be build with no reference to periods but thanks to the creation date
if context.get('periods',False):
#if one or more period are given, use them
fiscalperiod_ids = fiscalperiod_obj.search(cr, uid, [('id','in',context['periods'])])
else:
fiscalperiod_ids = self.pool.get('account.period').search(cr, uid, [('fiscalyear_id','in',fiscalyear_ids)])
#remove from the old query the clause related to the period selection
res = ''
count = 1
clause_list = query.split('AND')
ref_string = ' '+obj+'.period_id in'
for clause in clause_list:
if count != 1 and not clause.startswith(ref_string):
res += "AND"
if not clause.startswith(ref_string):
res += clause
count += 1
#add to 'res' a new clause containing the creation date criterion
count = 1
res += " AND ("
periods = self.pool.get('account.period').read(cr, uid, p_ids, ['date_start','date_stop'])
for period in periods:
if count != 1:
res += " OR "
#creation date criterion: the creation date of the move_line has to be
# between the date_start and the date_stop of the selected periods
res += "("+obj+".create_date between to_date('" + period['date_start'] + "','yyyy-mm-dd') and to_date('" + period['date_stop'] + "','yyyy-mm-dd'))"
count += 1
res += ")"
return res
return query
def default_get(self, cr, uid, fields, context={}):

View File

@ -118,7 +118,8 @@ class account_common_report(osv.osv_memory):
elif data['form']['filter'] == 'filter_period':
if not data['form']['period_from'] or not data['form']['period_to']:
raise osv.except_osv(_('Error'),_('Select a starting and an ending period'))
result['periods'] = period_obj.build_ctx_periods(cr, uid, data['form']['period_from'], data['form']['period_to'])
result['period_from'] = data['form']['period_from']
result['period_to'] = data['form']['period_to']
return result
def _print_report(self, cr, uid, ids, data, context=None):