From 4363de12dda2bcdd8aec1a2b2b8f7f774568ca01 Mon Sep 17 00:00:00 2001 From: pso Date: Fri, 12 Feb 2010 11:47:51 +0530 Subject: [PATCH] [FIX] account: Put domain for company analysis and improved read_group lp bug: https://launchpad.net/bugs/694876 fixed bzr revid: pso@tinyerp.com-20100212061751-7wd3qzvtjit8tra3 --- addons/account/board_account_view.xml | 1 + .../account/report/account_entries_report.py | 28 ++++++++----------- .../report/account_entries_report_view.xml | 4 +-- 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/addons/account/board_account_view.xml b/addons/account/board_account_view.xml index 673cdfab8e1..dd424e17ceb 100755 --- a/addons/account/board_account_view.xml +++ b/addons/account/board_account_view.xml @@ -27,6 +27,7 @@ tree,graph {'group_by':['user_type'], 'group_by_no_leaf':1} + [('year','=',time.strftime('%Y'))] Treasury diff --git a/addons/account/report/account_entries_report.py b/addons/account/report/account_entries_report.py index e80cb290889..7d419410458 100755 --- a/addons/account/report/account_entries_report.py +++ b/addons/account/report/account_entries_report.py @@ -94,25 +94,19 @@ class account_entries_report(osv.osv): return super(account_entries_report, self).search(cr, uid, args=args, offset=offset, limit=limit, order=order, context=context, count=count) - def read_group(self, cr, uid, domain, *args, **kwargs): - todel=[] + def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None, orderby=False): fiscalyear_obj = self.pool.get('account.fiscalyear') period_obj = self.pool.get('account.period') - for arg in domain: - if arg[0] == 'period_id' and arg[2] == 'current_period': - current_period = period_obj.find(cr, uid)[0] - domain.append(['period_id','in',[current_period]]) - todel.append(arg) - break - elif arg[0] == 'period_id' and arg[2] == 'current_year': - current_year = fiscalyear_obj.find(cr, uid) - ids = fiscalyear_obj.read(cr, uid, [current_year], ['period_ids'])[0]['period_ids'] - domain.append(['period_id','in',ids]) - todel.append(arg) - for a in [['period_id','in','current_year'], ['period_id','in','current_period']]: - if a in domain: - domain.remove(a) - return super(account_entries_report, self).read_group(cr, uid, domain, *args, **kwargs) + if context.get('period', False) == 'current_period': + current_period = period_obj.find(cr, uid)[0] + domain.append(['period_id','in',[current_period]]) + elif context.get('year', False) == 'current_year': + current_year = fiscalyear_obj.find(cr, uid) + ids = fiscalyear_obj.read(cr, uid, [current_year], ['period_ids'])[0]['period_ids'] + domain.append(['period_id','in',ids]) + else: + domain = domain + return super(account_entries_report, self).read_group(cr, uid, domain, fields, groupby, offset, limit, context, orderby) def init(self, cr): tools.drop_view_if_exists(cr, 'account_entries_report') diff --git a/addons/account/report/account_entries_report_view.xml b/addons/account/report/account_entries_report_view.xml index 8eefe75838f..da78476d96a 100755 --- a/addons/account/report/account_entries_report_view.xml +++ b/addons/account/report/account_entries_report_view.xml @@ -70,11 +70,11 @@