[FIX] account: print journal report bugfixed and refactored
bzr revid: qdp-launchpad@tinyerp.com-20100628145548-5hq5amgpus54jpn3
This commit is contained in:
parent
df2253bc9d
commit
7d59f83cc0
|
@ -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:
|
||||
#vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
|
@ -2,35 +2,16 @@
|
|||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="view_account_print_journal" model="ir.ui.view">
|
||||
<record id="account_report_print_journal" model="ir.ui.view">
|
||||
<field name="name">Account Print Journal</field>
|
||||
<field name="model">account.print.journal</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit_id" ref="account_common_report_view" />
|
||||
<field name="arch" type="xml">
|
||||
<form string="Print Journals">
|
||||
<group height="350" width="650">
|
||||
<group colspan="4">
|
||||
<separator string="Journals" colspan="4"/>
|
||||
<newline/>
|
||||
<field name="journal_ids" nolabel="1"/>
|
||||
<newline/>
|
||||
<separator string="Periods" colspan="4"/>
|
||||
<group colspan="4">
|
||||
<field name="period_from"/>
|
||||
<field name="period_to"/>
|
||||
</group>
|
||||
<group colspan="4">
|
||||
<separator string="" colspan="4" col="2"/>
|
||||
<field name="sort_selection" />
|
||||
</group>
|
||||
</group>
|
||||
</group>
|
||||
<separator colspan="4"/>
|
||||
<group col="2" colspan="4">
|
||||
<button special="cancel" string="Cancel" icon='gtk-cancel'/>
|
||||
<button name="check_report" string="Print" colspan="1" type="object" icon="gtk-ok"/>
|
||||
</group>
|
||||
</form>
|
||||
<field name="fiscalyear_id" position="after">
|
||||
<field name="sort_selection"/>
|
||||
<newline/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
@ -41,6 +22,7 @@
|
|||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
<field name="view_id" ref="account_report_print_journal"/>
|
||||
</record>
|
||||
|
||||
<menuitem
|
||||
|
@ -51,4 +33,4 @@
|
|||
icon="STOCK_PRINT"/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
</openerp>
|
||||
|
|
Loading…
Reference in New Issue