From 4bfa1390990b798d41d4fb8a4eeb2c767cd6e0d5 Mon Sep 17 00:00:00 2001 From: "pap@tinyerp.com" <> Date: Sat, 14 Aug 2010 20:00:22 +0530 Subject: [PATCH] [FIX]: improvement and fix proposed by the pap@tinyerp.com bzr revid: mga@tinyerp.com-20100814143022-7jks4ktnghiyqhtt --- .../account/report/account_entries_report.py | 36 +++++++++++++++++++ .../report/account_entries_report_view.xml | 16 ++++----- .../account/test/account_fiscalyear_close.yml | 2 +- 3 files changed, 45 insertions(+), 9 deletions(-) diff --git a/addons/account/report/account_entries_report.py b/addons/account/report/account_entries_report.py index 0aebe500c6f..1047453289c 100644 --- a/addons/account/report/account_entries_report.py +++ b/addons/account/report/account_entries_report.py @@ -70,6 +70,42 @@ class account_entries_report(osv.osv): 'company_id': fields.many2one('res.company', 'Company', readonly=True), } _order = 'date desc' + + def search(self, cr, uid, args, offset=0, limit=None, order=None, + context=None, count=False): + for arg in args: + if arg[0] == 'period_id' and arg[2] == 'current_period': + current_period = self.pool.get('account.period').find(cr, uid)[0] + args.append(['period_id','in',[current_period]]) + break + elif arg[0] == 'period_id' and arg[2] == 'current_year': + current_year = self.pool.get('account.fiscalyear').find(cr, uid) + ids = self.pool.get('account.fiscalyear').read(cr, uid, [current_year], ['period_ids'])[0]['period_ids'] + args.append(['period_id','in',ids]) + for a in [['period_id','in','current_year'], ['period_id','in','current_period']]: + if a in args: + args.remove(a) + 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, fields, groupby, offset=0, limit=None, context=None): + todel=[] + for arg in domain: + if arg[0] == 'period_id' and arg[2] == 'current_period': + current_period = self.pool.get('account.period').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 = self.pool.get('account.fiscalyear').find(cr, uid) + ids = self.pool.get('account.fiscalyear').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, fields, groupby, offset, limit, context) + def init(self, cr): tools.drop_view_if_exists(cr, 'account_entries_report') cr.execute(""" diff --git a/addons/account/report/account_entries_report_view.xml b/addons/account/report/account_entries_report_view.xml index 6259466bd2a..7a1746d2de1 100644 --- a/addons/account/report/account_entries_report_view.xml +++ b/addons/account/report/account_entries_report_view.xml @@ -52,14 +52,14 @@ - - + + diff --git a/addons/account/test/account_fiscalyear_close.yml b/addons/account/test/account_fiscalyear_close.yml index 5af4787c6a6..a305dd85417 100644 --- a/addons/account/test/account_fiscalyear_close.yml +++ b/addons/account/test/account_fiscalyear_close.yml @@ -47,7 +47,7 @@ I check the opening entries By using "Entries by Line wizard" - !record {model: account.move.journal, id: account_move_journal_0}: - journal_id: account.sales_journal + {} - I clicked on Open Journal Button to check the entries