[IMP] Common report class: pass fiscalyear id on change of filter

bzr revid: mra@mra-laptop-20100803072943-iza58lknsmxd3d0b
This commit is contained in:
Mustufa Rangwala 2010-08-03 12:59:43 +05:30
parent 1279a38f84
commit 834e555b32
2 changed files with 5 additions and 4 deletions

View File

@ -54,13 +54,13 @@ class account_common_report(osv.osv_memory):
res['arch'] = etree.tostring(doc)
return res
def onchange_filter(self, cr, uid, ids, filter='filter_no', context=None):
def onchange_filter(self, cr, uid, ids, filter='filter_no', fiscalyear_id=False, context=None):
res = {}
if filter == 'filter_no':
res['value'] = {'period_from': False, 'period_to': False, 'date_from': False ,'date_to': False}
if filter == 'filter_date':
res['value'] = {'period_from': False, 'period_to': False, 'date_from': time.strftime('%Y-01-01'), 'date_to': time.strftime('%Y-%m-%d')}
if filter == 'filter_period':
if filter == 'filter_period' and fiscalyear_id:
start_period = end_period = False
cr.execute('SELECT p.id FROM account_fiscalyear AS f \
LEFT JOIN account_period AS p on p.fiscalyear_id=f.id \
@ -70,7 +70,8 @@ class account_common_report(osv.osv_memory):
AND p.date_start IN \
(SELECT max(date_start) from account_period WHERE p.fiscalyear_id = f.id)\
OR p.date_stop IN \
(SELECT min(date_stop) from account_period WHERE p.fiscalyear_id = f.id)) ')
(SELECT min(date_stop) from account_period WHERE p.fiscalyear_id = f.id)) \
AND f.id = ' + str(fiscalyear_id) + ' ')
periods = [i[0] for i in cr.fetchall()]
if periods:
start_period = periods[0]

View File

@ -21,7 +21,7 @@
<group colspan="2" name='Filters'>
<notebook tabpos="up">
<page string="Filters">
<field name="filter" on_change="onchange_filter(filter)" />
<field name="filter" on_change="onchange_filter(filter, fiscalyear_id)" />
<separator string="Dates" colspan="4"/>
<field name="date_from" attrs="{'readonly':[('filter', '!=', 'filter_date')], 'required':[('filter', '=', 'filter_date')]}" colspan="4"/>
<field name="date_to" attrs="{'readonly':[('filter', '!=', 'filter_date')], 'required':[('filter', '=', 'filter_date')]}" colspan="4"/>