[IMP] add the currency field in general_journal report and improve the query of report
bzr revid: sbh@tinyerp.com-20100715072206-esj3qqk2ikd7wmz6
This commit is contained in:
parent
bc69052c7b
commit
cb806a8453
|
@ -294,7 +294,7 @@
|
|||
<td><para style="terp_default_8">[[ line.name ]]</para></td>
|
||||
<td><para style="P8">[[ formatLang(line.debit) ]]</para></td>
|
||||
<td><para style="P8">[[ formatLang(line.credit) ]]</para></td>
|
||||
<td><para style="P8">[[ formatLang(line.amount_currency) ]] [[ line.currency_code or '']]</para></td>
|
||||
<td><para style="P8">[[ formatLang(line.amount_currency) ]] [[ line.amount_currency.code or '']]</para></td>
|
||||
|
||||
</tr>
|
||||
</blockTable>
|
||||
|
|
|
@ -47,7 +47,8 @@ class journal_print(report_sxw.rml_parse, common_report_header):
|
|||
'get_account': self._get_account,
|
||||
'get_start_period': self.get_start_period,
|
||||
'get_end_period': self.get_end_period,
|
||||
'get_sortby': self._get_sortby
|
||||
'get_sortby': self._get_sortby,
|
||||
'sum_currency_amount_account': self._sum_currency_amount_account,
|
||||
})
|
||||
|
||||
def set_context(self, objects, data, ids, report_type=None): # Improve move to common default?
|
||||
|
@ -79,16 +80,37 @@ class journal_print(report_sxw.rml_parse, common_report_header):
|
|||
def lines(self, period_id, journal_id=[]):
|
||||
if not self.journal_ids:
|
||||
return []
|
||||
self.cr.execute('SELECT j.code, j.name, '
|
||||
self.cr.execute('SELECT j.code, j.name, l.amount_currency,c.code AS currency_code, '
|
||||
'SUM(l.debit) AS debit, SUM(l.credit) AS credit '
|
||||
'FROM account_move_line l '
|
||||
'LEFT JOIN account_journal j ON (l.journal_id=j.id) '
|
||||
'LEFT JOIN res_currency c on (l.currency_id=c.id)'
|
||||
'WHERE period_id=%s AND journal_id IN %s '+self.query_get_clause +''
|
||||
'GROUP BY j.id, j.code, j.name',
|
||||
'GROUP BY j.id, j.code, j.name, l.amount_currency,c.code ',
|
||||
(period_id, tuple(self.journal_ids)))
|
||||
|
||||
return self.cr.dictfetchall()
|
||||
def _set_get_account_currency_code(self, account_id):
|
||||
self.cr.execute("SELECT c.code as code "\
|
||||
"FROM res_currency c,account_account as ac "\
|
||||
"WHERE ac.id = %s AND ac.currency_id = c.id"%(account_id))
|
||||
result = self.cr.fetchone()
|
||||
if result:
|
||||
self.account_currency = result[0]
|
||||
else:
|
||||
self.account_currency = False
|
||||
|
||||
def _sum_currency_amount_account(self, account, form):
|
||||
self._set_get_account_currency_code(account.id)
|
||||
self.cr.execute("SELECT sum(aml.amount_currency) FROM account_move_line as aml,res_currency as rc WHERE aml.currency_id = rc.id AND aml.account_id= %s ", (account.id,))
|
||||
total = self.cr.fetchone()
|
||||
|
||||
if self.account_currency:
|
||||
return_field = str(total[0]) + self.account_currency
|
||||
return return_field
|
||||
else:
|
||||
currency_total = self.tot_currency = 0.0
|
||||
return currency_total
|
||||
report_sxw.report_sxw('report.account.general.journal', 'account.journal.period', 'addons/account/report/general_journal.rml', parser=journal_print, header=False)
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -47,11 +47,11 @@
|
|||
<blockTableStyle id="Table_Journal_Title">
|
||||
<blockAlignment value="LEFT"/>
|
||||
<blockValign value="TOP"/>
|
||||
<lineStyle kind="LINEBELOW" colorName="#000000" start="0,-1" stop="0,-1"/>
|
||||
<lineStyle kind="LINEBELOW" colorName="#000000" start="1,-1" stop="1,-1"/>
|
||||
<lineStyle kind="LINEBELOW" colorName="#000000" start="2,-1" stop="2,-1"/>
|
||||
<lineStyle kind="LINEBELOW" colorName="#000000" start="3,-1" stop="3,-1"/>
|
||||
<lineStyle kind="LINEBELOW" colorName="#000000" start="4,-1" stop="4,-1"/>
|
||||
<lineStyle kind="LINEBELOW" colorName="#000000" start="0,0" stop="-1,0"/>
|
||||
<lineStyle kind="LINEBELOW" colorName="#000000" start="0,1" stop="-1,1"/>
|
||||
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="0,2" stop="-1,-1"/>
|
||||
<lineStyle kind="LINEBELOW" colorName="#000000" start="0,0" stop="-1,0"/>
|
||||
<lineStyle kind="LINEBELOW" colorName="#000000" start="0,1" stop="-1,1"/>
|
||||
</blockTableStyle>
|
||||
<blockTableStyle id="Table_Final_Total">
|
||||
<blockAlignment value="LEFT"/>
|
||||
|
@ -185,6 +185,7 @@
|
|||
</stylesheet>
|
||||
<images/>
|
||||
<story>
|
||||
<para style="terp_default_8">[[ repeatIn( periods(objects), 'o') ]]</para>
|
||||
<para style="P9">
|
||||
<font color="white"> </font>
|
||||
</para>
|
||||
|
@ -240,7 +241,7 @@
|
|||
<para style="P9">
|
||||
<font color="white"> </font>
|
||||
</para>
|
||||
<blockTable colWidths="72.0,218.0,89.0,83.0,77.0" style="Table_Journal_Title">
|
||||
<blockTable colWidths="72.0,218.0,89.0,83.0,77.0" style="Table_Journal_Title" repeatRows="1">[[ data['form']['amount_currency'] == False or removeParentNode('blockTable') ]]
|
||||
<tr>
|
||||
<td><para style="terp_tblheader_Details">Code</para></td>
|
||||
<td><para style="terp_tblheader_Details">Journal Name</para></td>
|
||||
|
@ -248,8 +249,6 @@
|
|||
<td><para style="terp_tblheader_Details_Right">Debit</para></td>
|
||||
<td><para style="terp_tblheader_Details_Right">Credit</para></td>
|
||||
</tr>
|
||||
</blockTable>
|
||||
<blockTable colWidths="71.0,219.0,89.0,83.0,77.0" style="Table_Final_Total">
|
||||
<tr>
|
||||
<td><para style="terp_default_Bold_9">Total:</para></td>
|
||||
<td><para style="terp_default_Bold_9"><font color="white"> </font></para></td>
|
||||
|
@ -258,36 +257,27 @@
|
|||
<td><para style="terp_default_Bold_9_Right">[[ formatLang( sum_credit()) ]]</para></td>
|
||||
</tr>
|
||||
</blockTable>
|
||||
<blockTable colWidths="70.0,180.0,70.0,73.0,77.0,60.0" style="Table_Journal_Title" repeatRows="1">[[ data['form']['amount_currency'] == True or removeParentNode('blockTable') ]]
|
||||
<tr>
|
||||
<td><para style="terp_tblheader_Details">Code</para></td>
|
||||
<td><para style="terp_tblheader_Details">Journal Name</para></td>
|
||||
<td><para style="terp_tblheader_Details">Period</para></td>
|
||||
<td><para style="terp_tblheader_Details_Right">Debit</para></td>
|
||||
<td><para style="terp_tblheader_Details_Right">Credit</para></td>
|
||||
<td><para style="terp_tblheader_Details_Right">Currency</para></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><para style="terp_default_Bold_9">Total:</para></td>
|
||||
<td><para style="terp_default_Bold_9"><font color="white"> </font></para></td>
|
||||
<td><para style="terp_default_Bold_9">[[ o.name ]]</para></td>
|
||||
<td><para style="terp_default_Bold_9_Right">[[ formatLang(sum_debit()) ]]</para></td>
|
||||
<td><para style="terp_default_Bold_9_Right">[[ formatLang( sum_credit()) ]]</para></td>
|
||||
<td><para style="terp_default_Bold_9_Right"><u>[[formatLang(sum_currency_amount_account(o, data['form'])) ]]</u></para></td>
|
||||
</tr>
|
||||
</blockTable>
|
||||
|
||||
<section>
|
||||
<para style="terp_default_8">[[ repeatIn( periods(objects), 'o') ]]</para>
|
||||
<blockTable colWidths="176.0,115.0,89.0,83.0,76.0" style="Table_Sub_Total">
|
||||
<tr>
|
||||
<td>
|
||||
<para style="terp_default_Bold_9">[[ o.name ]] :</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="terp_default_Bold_9">
|
||||
<font color="white"> </font>
|
||||
</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="terp_default_Bold_9">
|
||||
<font color="white"> </font>
|
||||
</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="terp_default_Bold_9_Right">[[ formatLang(sum_debit_period(o.id)) ]]</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="terp_default_Bold_9_Right">[[ formatLang(sum_credit_period(o.id)) ]]</para>
|
||||
</td>
|
||||
</tr>
|
||||
</blockTable>
|
||||
<para style="terp_default_2">
|
||||
<font color="white"> </font>
|
||||
</para>
|
||||
<blockTable colWidths="71.0,219.0,91.0,83.0,76.0" style="Table_Journal_Detail">
|
||||
<blockTable colWidths="71.0,219.0,91.0,83.0,76.0" style="Table_Journal_Detail">[[ data['form']['amount_currency'] == False or removeParentNode('blockTable') ]]
|
||||
<tr>
|
||||
<td>
|
||||
<para style="terp_default_9"><font face="Times-Roman">[[ repeatIn(lines(o.id),'line')]]</font> [[ line['code'] ]]</para>
|
||||
|
@ -306,6 +296,16 @@
|
|||
</td>
|
||||
</tr>
|
||||
</blockTable>
|
||||
<blockTable colWidths="70.0,180.0,70.0,73.0,77.0,60.0" style="Table_Journal_Detail">[[ data['form']['amount_currency'] == True or removeParentNode('blockTable') ]]
|
||||
<tr>
|
||||
<td><para style="terp_default_9"><font>[[ repeatIn(lines(o.id),'line')]]</font> [[ line['code'] ]]</para></td>
|
||||
<td><para style="terp_default_9">[[ line['name'] ]]</para></td>
|
||||
<td><para style="terp_default_9">[[ o.name ]]</para></td>
|
||||
<td><para style="terp_default_Right_9">[[ formatLang(line['debit'] )]]</para></td>
|
||||
<td><para style="terp_default_Right_9">[[ formatLang(line['credit']) ]]</para></td>
|
||||
<td><para style="terp_default_Right_9"><u>[[ formatLang(line['amount_currency'] ) ]] [[ line['currency_code'] ]]</u></para></td>
|
||||
</tr>
|
||||
</blockTable>
|
||||
<para style="terp_default_2">
|
||||
<font color="white"> </font>
|
||||
</para>
|
||||
|
|
Loading…
Reference in New Issue