From 508c6bd2753dfd62ffb30345bca626d4ae39e9f6 Mon Sep 17 00:00:00 2001 From: "Jay (Open ERP)" Date: Tue, 17 Mar 2009 19:03:56 +0530 Subject: [PATCH] [FIX] Bug 327394 :Improved Report (ref:VRA) bzr revid: jvo@tinyerp.com-20090317133356-npnhrgytvsnhovfl --- addons/account/report/account_balance.py | 26 ++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/addons/account/report/account_balance.py b/addons/account/report/account_balance.py index e74ad786365..d61c992d225 100644 --- a/addons/account/report/account_balance.py +++ b/addons/account/report/account_balance.py @@ -60,17 +60,31 @@ class account_balance(report_sxw.rml_parse): if form.has_key('periods') and form['periods'][0][2]: 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)) - res=self.cr.fetchall() + res = self.cr.fetchall() + len_res = len(res) for r in res: - if (r == res[res.__len__()-1]): + if (r == res[len_res-1]): result+=r[0]+". " else: result+=r[0]+", " + else: + fy_obj = self.pool.get('account.fiscalyear').browse(self.cr,self.uid,form['fiscalyear']) + res = fy_obj.period_ids + len_res = len(res) + for r in res: + if r == res[len_res-1]: + result+=r.name+". " + else: + result+=r.name+", " + return str(result and result[:-1]) or '' def transform_both_into_date_array(self,data): - if not data['periods'][0][2] : - periods_id = self.pool.get('account.period').search(self.cr, self.uid, [('fiscalyear_id','=',data['form']['fiscalyear'])]) + + if not data['periods'][0][2]: + if not form['fiscalyear']: + return True + periods_id = self.pool.get('account.period').search(self.cr, self.uid, [('fiscalyear_id','=',form['fiscalyear'])]) else: periods_id = data['periods'][0][2] date_array = [] @@ -127,10 +141,14 @@ class account_balance(report_sxw.rml_parse): ctx['fiscalyear'] = form['fiscalyear'] ctx['periods'] = form['periods'][0][2] elif form['state']== 'bydate': + ctx['fiscalyear'] = form['fiscalyear'] ctx['date_from'] = form['date_from'] ctx['date_to'] = form['date_to'] self.transform_date_into_date_array(form) elif form['state'] == 'all' : + ctx['fiscalyear'] = form['fiscalyear'] + ctx['date_from'] = form['date_from'] + ctx['date_to'] = form['date_to'] self.transform_both_into_date_array(form) elif form['state'] == 'none' : self.transform_none_into_date_array(form)