From 834e555b32502d849e87cc7c2d112b1a5180b31b Mon Sep 17 00:00:00 2001 From: Mustufa Rangwala Date: Tue, 3 Aug 2010 12:59:43 +0530 Subject: [PATCH] [IMP] Common report class: pass fiscalyear id on change of filter bzr revid: mra@mra-laptop-20100803072943-iza58lknsmxd3d0b --- addons/account/wizard/account_report_common.py | 7 ++++--- addons/account/wizard/account_report_common_view.xml | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/addons/account/wizard/account_report_common.py b/addons/account/wizard/account_report_common.py index 9836b9dc467..5189669f872 100644 --- a/addons/account/wizard/account_report_common.py +++ b/addons/account/wizard/account_report_common.py @@ -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] diff --git a/addons/account/wizard/account_report_common_view.xml b/addons/account/wizard/account_report_common_view.xml index 528b6132834..3779a03a7be 100644 --- a/addons/account/wizard/account_report_common_view.xml +++ b/addons/account/wizard/account_report_common_view.xml @@ -21,7 +21,7 @@ - +