From ca7e9ece6989031f444f4ca698978b055ee95233 Mon Sep 17 00:00:00 2001 From: Mustufa Rangwala Date: Mon, 12 Jul 2010 11:12:20 +0530 Subject: [PATCH] [IMP] Make default for filter on journal wizards bzr revid: mra@mra-laptop-20100712054220-o5btsche3x483l9o --- addons/account/report/account_journal.py | 3 ++- addons/account/report/account_journal.rml | 2 +- .../account/report/account_journal_common_default.py | 12 +++++++++++- addons/account/report/central_journal.py | 1 + addons/account/report/general_journal.py | 3 ++- addons/account/wizard/account_common_report.py | 3 ++- 6 files changed, 19 insertions(+), 5 deletions(-) diff --git a/addons/account/report/account_journal.py b/addons/account/report/account_journal.py index 17379a5e58d..b9bb1e78913 100644 --- a/addons/account/report/account_journal.py +++ b/addons/account/report/account_journal.py @@ -58,7 +58,8 @@ class journal_print(report_sxw.rml_parse, account_journal_common_default): 'sum_credit': self._sum_credit, 'get_start_period': self.get_start_period, 'get_end_period': self.get_end_period, - 'get_account': self.get_account + 'get_account': self._get_account, + 'get_filter': self._get_filter }) def lines(self, period_id, journal_id=[]): diff --git a/addons/account/report/account_journal.rml b/addons/account/report/account_journal.rml index 543c16bb069..eb445bd813f 100644 --- a/addons/account/report/account_journal.rml +++ b/addons/account/report/account_journal.rml @@ -225,7 +225,7 @@ [[ get_account(data) or removeParentNode('para') ]] [[ get_start_period(data) or removeParentNode('para') ]] [[ get_end_period(data) or removeParentNode('para') ]] - [[ data and 'form' in data and data['form']['filter'] or 'No Filter' ]] + [[ get_filter(data) or removeParentNode('para') ]] [[ formatLang(time.strftime('%Y-%m-%d %H:%M:%S'), date_time = True) ]] diff --git a/addons/account/report/account_journal_common_default.py b/addons/account/report/account_journal_common_default.py index d1dd0242e88..fcea5cdae26 100644 --- a/addons/account/report/account_journal_common_default.py +++ b/addons/account/report/account_journal_common_default.py @@ -71,11 +71,21 @@ class account_journal_common_default(object): return pooler.get_pool(self.cr.dbname).get('account.period').browse(self.cr, self.uid, data['form']['period_to']).name return '' - def get_account(self, data): + def _get_account(self, data): if data.get('form', False) and data['form'].get('chart_account_id', False): return pooler.get_pool(self.cr.dbname).get('account.account').browse(self.cr, self.uid, data['form']['chart_account_id']).name return '' + def _get_filter(self, data): + if data.get('form', False) and data['form'].get('filter', False): + if data['form']['filter'] == 'filter_date': + return 'Date' + elif data['form']['filter'] == 'filter_period': + return 'Periods' + else: + return 'No Filter' + return '' + def _sum_debit_period(self, period_id, journal_id=None): journals = journal_id or self.journal_ids if not journals: diff --git a/addons/account/report/central_journal.py b/addons/account/report/central_journal.py index 48de00c2d91..857d7f0aab0 100644 --- a/addons/account/report/central_journal.py +++ b/addons/account/report/central_journal.py @@ -54,6 +54,7 @@ class journal_print(report_sxw.rml_parse, account_journal_common_default): 'lines': self.lines, 'sum_debit': self._sum_debit, 'sum_credit': self._sum_credit, + 'get_filter': self._get_filter # 'get_start_date': self.get_start_date, # 'get_end_date': self.get_end_date }) diff --git a/addons/account/report/general_journal.py b/addons/account/report/general_journal.py index 39c8fd0f16a..283ddad8f57 100644 --- a/addons/account/report/general_journal.py +++ b/addons/account/report/general_journal.py @@ -43,7 +43,8 @@ class journal_print(report_sxw.rml_parse, account_journal_common_default): 'sum_debit': self._sum_debit, 'sum_credit': self._sum_credit, 'get_start_date': self.get_start_date, - 'get_end_date': self.get_end_date + 'get_end_date': self.get_end_date, + 'get_filter': self._get_filter }) def set_context(self, objects, data, ids, report_type=None): diff --git a/addons/account/wizard/account_common_report.py b/addons/account/wizard/account_common_report.py index ec568f56eb1..4bbc5c8839d 100644 --- a/addons/account/wizard/account_common_report.py +++ b/addons/account/wizard/account_common_report.py @@ -31,7 +31,7 @@ class account_common_report(osv.osv_memory): _columns = { 'chart_account_id': fields.many2one('account.account', 'Chart of account', help='Select Charts of Accounts', required=True, domain = [('parent_id','=',False)]), 'fiscalyear_id': fields.many2one('account.fiscalyear', 'Fiscal year', help='Keep empty for all open fiscal year'), - 'filter': fields.selection([('filter_no', 'No filters'), ('filter_date', 'Date'), ('filter_period', 'Periods')], "Filter by:", required=True), + 'filter': fields.selection([('filter_no', 'No Filters'), ('filter_date', 'Date'), ('filter_period', 'Periods')], "Filter by:", required=True), 'period_from': fields.many2one('account.period', 'Start period'), 'period_to': fields.many2one('account.period', 'End period'), #not used. Do we really need it? 'period_ids': fields.many2many('account.period', 'ledger_period_rel', 'ledger_id', 'period_id', 'Periods'), @@ -122,6 +122,7 @@ class account_common_report(osv.osv_memory): else: data['form']['periods'] = [] return self._print_report(cr, uid, ids, data, query_line, context=context) + account_common_report() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: