From 931e97624b9b4b217529bbd36be50bfbdded0660 Mon Sep 17 00:00:00 2001 From: Jay Vora Date: Mon, 28 Jul 2008 19:17:57 +0530 Subject: [PATCH] solved error of fiscal year and period in report-account_balance.py bzr revid: jvo@tinyerp.com-20080728134757-lll1l23vo829ox8z --- addons/account/report/account_balance.py | 25 ++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/addons/account/report/account_balance.py b/addons/account/report/account_balance.py index 275158112d2..073487addef 100644 --- a/addons/account/report/account_balance.py +++ b/addons/account/report/account_balance.py @@ -44,16 +44,29 @@ class account_balance(report_sxw.rml_parse): 'get_periods':self.get_periods, }) self.context = context - + def get_fiscalyear(self, form): fisc_id = form['fiscalyear'] - self.cr.execute("select name from account_fiscalyear where id = %d" %(int(fisc_id))) - res=self.cr.fetchone() - return res and res[0] or '' + if fisc_id: + self.cr.execute("select name from account_fiscalyear where id = %d" %(int(fisc_id))) + else: + self.cr.execute("select name from account_fiscalyear where state='draft'") + res=self.cr.fetchall() + result='' + for r in res: + result+=r[0]+"," + return str(result and result[:-1]) or '' def get_periods(self, form): - period_ids = ",".join([str(x) for x in form['periods'][0][2] if x]) - self.cr.execute("select name from account_period where id in (%s)" % (period_ids)) + periods=form['periods'][0][2] + if periods: + period_ids = ",".join([str(x) for x in form['periods'][0][2] if x]) + self.cr.execute("select name from account_period where id in (%s)" % (period_ids)) + else: + if form['fiscalyear']: + self.cr.execute("select name from account_period where fiscalyear_id = %d"%(int(form['fiscalyear']))) + else: + self.cr.execute("select name from account_period") res=self.cr.fetchall() result='' for r in res: