[IMP] account: General journal report update with osv memory (ref: PSI)
bzr revid: mra@mra-laptop-20100625122359-ivvogx5pco2ov50n
This commit is contained in:
parent
307d40f4b1
commit
ffc09cf64d
|
@ -36,14 +36,14 @@ class journal_print(report_sxw.rml_parse):
|
|||
'sum_debit_period': self._sum_debit_period,
|
||||
'sum_credit_period': self._sum_credit_period,
|
||||
'sum_debit': self._sum_debit,
|
||||
'sum_credit': self._sum_credit
|
||||
'sum_credit': self._sum_credit,
|
||||
})
|
||||
|
||||
def set_context(self, objects, data, ids, report_type = None):
|
||||
def set_context(self, objects, data, ids, report_type=None):
|
||||
super(journal_print, self).set_context(objects, data, ids, report_type)
|
||||
self.cr.execute('SELECT period_id, journal_id '
|
||||
'FROM account_journal_period '
|
||||
'WHERE id IN %s',
|
||||
'FROM account_journal_period '
|
||||
'WHERE id IN %s',
|
||||
(tuple(ids),))
|
||||
res = self.cr.fetchall()
|
||||
self.period_ids, self.journal_ids = zip(*res)
|
||||
|
@ -91,7 +91,6 @@ class journal_print(report_sxw.rml_parse):
|
|||
return lines_data
|
||||
if not self.journal_ids:
|
||||
return []
|
||||
|
||||
self.cr.execute('SELECT j.code, j.name, '
|
||||
'SUM(l.debit) AS debit, SUM(l.credit) AS credit '
|
||||
'FROM account_move_line l '
|
||||
|
@ -146,7 +145,7 @@ class journal_print(report_sxw.rml_parse):
|
|||
'AND state<>\'draft\'',
|
||||
(tuple(periods), tuple(journals)))
|
||||
return self.cr.fetchone()[0] or 0.0
|
||||
report_sxw.report_sxw('report.account.general.journal', 'account.journal.period', 'addons/account/report/general_journal.rml', parser=journal_print)
|
||||
report_sxw.report_sxw('report.account.general.journal', 'account.journal.period', 'addons/account/report/general_journal.rml', parser=journal_print, header=False)
|
||||
report_sxw.report_sxw('report.account.general.journal.wiz', 'account.journal.period', 'addons/account/report/wizard_general_journal.rml', parser=journal_print, header=False)
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
|
@ -178,10 +178,10 @@
|
|||
</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="terp_default_Bold_9_Right"><u>[[ formatLang(sum_debit(data['form']['period_id'][0][2],data['form']['journal_id'][0][2])) ]]</u></para>
|
||||
<para style="terp_default_Bold_9_Right"><u>[[ formatLang(sum_debit(data['form']['periods'],data['form']['journal_ids'])) ]]</u></para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="terp_default_Bold_9_Right"><u>[[ formatLang(sum_credit(data['form']['period_id'][0][2],data['form']['journal_id'][0][2])) ]]</u></para>
|
||||
<para style="terp_default_Bold_9_Right"><u>[[ formatLang(sum_credit(data['form']['periods'],data['form']['journal_ids'])) ]]</u></para>
|
||||
</td>
|
||||
</tr>
|
||||
</blockTable>
|
||||
|
@ -191,7 +191,7 @@
|
|||
<tr>
|
||||
<td>
|
||||
|
||||
<para style="terp_default_9"><font>[[ repeatIn( lines( data['form']['period_id'][0][2], data['form']['journal_id'][0][2] ),'line')]]</font></para>
|
||||
<para style="terp_default_9"><font>[[ repeatIn( lines( data['form']['periods'], data['form']['journal_ids'] ),'line')]]</font></para>
|
||||
<blockTable colWidths="175.0,115.0,82.0,82.0,75.0" style="Table_Sub_Total">
|
||||
<tr>
|
||||
<td>
|
||||
|
@ -208,10 +208,10 @@
|
|||
</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="terp_default_Bold_9_Right"><u>[[ formatLang(sum_debit_period( line[0]['pid'],data['form']['journal_id'][0][2])) ]]</u></para>
|
||||
<para style="terp_default_Bold_9_Right"><u>[[ formatLang(sum_debit_period( line[0]['pid'],data['form']['journal_ids'])) ]]</u></para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="terp_default_Bold_9_Right"><u>[[ formatLang(sum_credit_period(line[0]['pid'],data['form']['journal_id'][0][2])) ]]</u></para>
|
||||
<para style="terp_default_Bold_9_Right"><u>[[ formatLang(sum_credit_period(line[0]['pid'],data['form']['journal_ids'])) ]]</u></para>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
|
|
@ -22,23 +22,29 @@ from osv import osv, fields
|
|||
from tools.translate import _
|
||||
|
||||
class account_general_journal(osv.osv_memory):
|
||||
_inherit = "account.common.report"
|
||||
_name = 'account.general.journal'
|
||||
_description = 'Account General Journal'
|
||||
|
||||
_columns = {
|
||||
'journal_id': fields.many2many('account.journal', 'account_journal_rel', 'account_id', 'journal_id', 'Journals', required=True),
|
||||
'period_id': fields.many2many('account.period', 'account_period_rel', 'account_id', 'period_id', 'Periods', required=True),
|
||||
}
|
||||
def _build_context(self, cr, uid, ids, data, context=None):
|
||||
period_obj = self.pool.get('account.period')
|
||||
result = super(account_general_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 check_data(self, cr, uid, ids, context=None):
|
||||
def _print_report(self, cr, uid, ids, data, query_line, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
obj_jperiod = self.pool.get('account.journal.period')
|
||||
datas = {}
|
||||
datas['ids'] = []
|
||||
datas['model'] = 'account.journal.period'
|
||||
datas['form'] = self.read(cr, uid, ids)[0]
|
||||
period_id = datas['form']['period_id']
|
||||
journal_id = datas['form']['journal_id']
|
||||
|
||||
period_id = data['form']['periods']
|
||||
journal_id = data['form']['journal_ids']
|
||||
if type(period_id)==type([]):
|
||||
ids_final = []
|
||||
for journal in journal_id:
|
||||
|
@ -48,12 +54,13 @@ class account_general_journal(osv.osv_memory):
|
|||
ids_final.append(ids_journal_period)
|
||||
if not ids_final:
|
||||
raise osv.except_osv(_('No Data Available'), _('No records found for your selection!'))
|
||||
return {
|
||||
'type': 'ir.actions.report.xml',
|
||||
'report_name': 'account.general.journal',
|
||||
'datas': datas,
|
||||
'nodestroy':True,
|
||||
}
|
||||
data['ids'] = []
|
||||
data['form']['query_get'] = query_line
|
||||
if data['model'] == 'ir.ui.menu':
|
||||
return {'type': 'ir.actions.report.xml', 'report_name': 'account.general.journal.wiz', 'datas': data, 'nodestroy':True, }
|
||||
else:
|
||||
return {'type': 'ir.actions.report.xml', 'report_name': 'account.general.journal', 'datas': data, 'nodestroy':True, }
|
||||
|
||||
account_general_journal()
|
||||
|
||||
#vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -7,17 +7,22 @@
|
|||
<field name="model">account.general.journal</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Print General Journal">
|
||||
<group col="4" colspan="6">
|
||||
<field name="journal_id"/>
|
||||
<field name="period_id"/>
|
||||
</group>
|
||||
<separator colspan="4"/>
|
||||
<group col="2" colspan="4">
|
||||
<button special="cancel" string="Cancel" icon='gtk-cancel'/>
|
||||
<button name="check_data" string="Print" colspan="1" type="object" icon="gtk-ok"/>
|
||||
</group>
|
||||
</form>
|
||||
<form string="Print General Journal">
|
||||
<group height="320" width="560">
|
||||
<separator string="Journals" colspan="4"/>
|
||||
<field name="journal_ids" nolabel="1" colspan="4"/>
|
||||
<separator string="Periods" colspan="4"/>
|
||||
<group colspan="4">
|
||||
<field name="period_from"/>
|
||||
<field name="period_to"/>
|
||||
</group>
|
||||
<group>
|
||||
<separator colspan="4"/>
|
||||
<button special="cancel" string="Cancel" icon="gtk-cancel"/>
|
||||
<button name="check_report" string="Print" colspan="1" type="object" icon="gtk-ok"/>
|
||||
</group>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
|
Loading…
Reference in New Issue