From 7d59f83cc0ce0f8f9363b35f2f2755d53b679e4e Mon Sep 17 00:00:00 2001 From: "qdp-launchpad@tinyerp.com" <> Date: Mon, 28 Jun 2010 16:55:48 +0200 Subject: [PATCH] [FIX] account: print journal report bugfixed and refactored bzr revid: qdp-launchpad@tinyerp.com-20100628145548-5hq5amgpus54jpn3 --- .../account/wizard/account_print_journal.py | 44 ++++--------------- .../wizard/account_print_journal_view.xml | 34 ++++---------- 2 files changed, 17 insertions(+), 61 deletions(-) diff --git a/addons/account/wizard/account_print_journal.py b/addons/account/wizard/account_print_journal.py index cba3794ad90..fa4624238e2 100644 --- a/addons/account/wizard/account_print_journal.py +++ b/addons/account/wizard/account_print_journal.py @@ -27,49 +27,23 @@ class account_print_journal(osv.osv_memory): _description = 'Account Print Journal' _columns = { - 'sort_selection': fields.selection([('date','By Date'), - ('ref','By Reference Number'),], + 'sort_selection': fields.selection([('date', 'Date'), + ('ref', 'Reference Number'),], 'Entries Sorted By', required=True), - } + } _defaults = { 'sort_selection': 'date', - } - - def _build_context(self, cr, uid, ids, data, context=None): - period_obj = self.pool.get('account.period') - result = super(account_print_journal, self)._build_context(cr, uid, ids, data, context=context) - if not data['form']['period_from'] or not data['form']['period_to']: - raise osv.except_osv(_('Error'),_('Select Start period and End period')) - elif (data['form']['period_from'] > data['form']['period_to']): - raise osv.except_osv(_('Error'),_('Start period should be smaller then End period')) - period_date_start = period_obj.read(cr, uid, data['form']['period_from'], ['date_start'])['date_start'] - period_date_stop = period_obj.read(cr, uid, data['form']['period_to'], ['date_stop'])['date_stop'] - cr.execute('SELECT id FROM account_period WHERE date_start >= %s AND date_stop <= %s', (period_date_start, period_date_stop)) - result.update({'periods': map(lambda x: x[0], cr.fetchall())}) - return result - + } def _print_report(self, cr, uid, ids, data, query_line, context=None): - obj_jperiod = self.pool.get('account.journal.period') - period_id = data['form']['periods'] - journal_id = data['form']['journal_ids'] - if type(period_id) ==type([]): - ids_final = [] - for journal in journal_id: - for period in period_id: - ids_journal_period = obj_jperiod.search(cr,uid, [('journal_id','=',journal),('period_id','=',period)], context=context) - if ids_journal_period: - ids_final.append(ids_journal_period) - if not ids_final: - raise osv.except_osv(_('No Data Available'), _('No records found for your selection!')) data['form'].update(self.read(cr, uid, ids, ['sort_selection'])[0]) + fy_ids = data['form']['fiscalyear_id'] and [data['form']['fiscalyear_id']] or self.pool.get('account.fiscalyear').search(cr, uid, [('state', '=', 'draft')], context=context) + period_list = data['form']['periods'] or self.pool.get('account.period').search(cr, uid, [('fiscalyear_id', 'in', fy_ids)], context=context) + data['form']['active_ids'] = self.pool.get('account.journal.period').search(cr, uid, [('journal_id', 'in', data['form']['journal_ids']), ('period_id', 'in', period_list)], context=context) data['form']['query_get'] = query_line - if data['model'] == 'ir.ui.menu': - return { 'type': 'ir.actions.report.xml', 'report_name': 'account.journal.period.print.wiz', 'datas': data, 'nodestroy':True, } - else: - return { 'type': 'ir.actions.report.xml', 'report_name': 'account.journal.period.print', 'datas': data, 'nodestroy':True, } + return { 'type': 'ir.actions.report.xml', 'report_name': 'account.journal.period.print', 'datas': data, 'nodestroy':True, } account_print_journal() -#vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +#vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/wizard/account_print_journal_view.xml b/addons/account/wizard/account_print_journal_view.xml index 1948653c0a9..ac43dbbff55 100644 --- a/addons/account/wizard/account_print_journal_view.xml +++ b/addons/account/wizard/account_print_journal_view.xml @@ -2,35 +2,16 @@ - + Account Print Journal account.print.journal form + -
- - - - - - - - - - - - - - - - - - - -