[IMP] add the currency field in central_journal report

bzr revid: sbh@tinyerp.com-20100715065018-0ntwzeg68guk0wtz
This commit is contained in:
sbh (Open ERP) 2010-07-15 12:20:18 +05:30
parent 6cd1bfb3e0
commit b69f893cd8
3 changed files with 82 additions and 7 deletions

View File

@ -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.currency_code or '']]</para></td>
</tr>
</blockTable>

View File

@ -45,7 +45,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?
@ -63,10 +64,30 @@ class journal_print(report_sxw.rml_parse, common_report_header):
return super(journal_print, self).set_context(objects, data, ids, report_type)
def lines(self, period_id, journal_id):
self.cr.execute('SELECT a.code, a.name, SUM(debit) AS debit, SUM(credit) AS credit from account_move_line l LEFT JOIN account_account a ON (l.account_id=a.id) WHERE l.period_id=%s AND l.journal_id=%s '+self.query_get_clause+' GROUP BY a.id, a.code, a.name', (period_id, journal_id))
self.cr.execute('SELECT a.code, a.name, c.code AS currency_code, l.amount_currency ,SUM(debit) AS debit, SUM(credit) AS credit from account_move_line l LEFT JOIN account_account a ON (l.account_id=a.id) LEFT JOIN res_currency c on (l.currency_id=c.id)WHERE l.period_id=%s AND l.journal_id=%s '+self.query_get_clause+' GROUP BY a.id, a.code, a.name,l.amount_currency,c.code ', (period_id, journal_id))
res = self.cr.dictfetchall()
return res
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.central.journal', 'account.journal.period', 'addons/account/report/central_journal.rml', parser=journal_print, header=False)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -121,6 +121,15 @@
<lineStyle kind="LINEBELOW" colorName="#000000" start="2,-1" stop="2,-1"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="3,-1" stop="3,-1"/>
</blockTableStyle>
<blockTableStyle id="Table_Account_detail_Title_Currency">
<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"/>
</blockTableStyle>
<blockTableStyle id="Table_Final_Total">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
@ -128,6 +137,15 @@
<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"/>
</blockTableStyle>
<blockTableStyle id="Table_Final_Total_currency">
<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"/>
</blockTableStyle>
<blockTableStyle id="Table_Journal_Line_Content">
<blockAlignment value="LEFT"/>
@ -137,6 +155,15 @@
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="2,-1" stop="2,-1"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="3,-1" stop="3,-1"/>
</blockTableStyle>
<blockTableStyle id="Table_Journal_Line_Content_currency">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="0,-1" stop="0,-1"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="1,-1" stop="1,-1"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="2,-1" stop="2,-1"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="3,-1" stop="3,-1"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="4,-1" stop="4,-1"/>
</blockTableStyle>
<initialize>
<paraStyle name="all" alignment="justify"/>
</initialize>
@ -225,18 +252,27 @@
<para style="P9">
<font color="white"> </font>
</para>
<blockTable colWidths="83.0,269.0,95.0,92.0" style="Table_Account_detail_Title">
<blockTable colWidths="83.0,269.0,95.0,92.0" style="Table_Account_detail_Title">[[ data['form']['amount_currency'] == False or removeParentNode('blockTable') ]]
<tr>
<td><para style="terp_tblheader_Details">Account Num.</para></td>
<td><para style="terp_tblheader_Details">A/C No.</para></td>
<td><para style="terp_tblheader_Details">Account Name</para></td>
<td><para style="terp_tblheader_Details_Right">Debit</para></td>
<td><para style="terp_tblheader_Details_Right">Credit</para></td>
</tr>
</blockTable>
<blockTable colWidths="83.0,200.0,95.0,92.0,69.0" style="Table_Account_detail_Title_Currency">[[ data['form']['amount_currency'] == True or removeParentNode('blockTable') ]]
<tr>
<td><para style="terp_tblheader_Details">A/C No.</para></td>
<td><para style="terp_tblheader_Details">Account Name</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>
</blockTable>
<para style="terp_default_2">
<font color="white"> </font>
</para>
<blockTable colWidths="83.0,269.0,94.0,92.0" style="Table_Final_Total">
<blockTable colWidths="83.0,269.0,94.0,92.0" style="Table_Final_Total">[[ data['form']['amount_currency'] == False or removeParentNode('blockTable') ]]
<tr>
<td><para style="terp_default_Bold_9">Total:</para></td>
<td><para style="terp_default_Bold_9"><font color="white"> </font></para></td>
@ -244,12 +280,21 @@
<td><para style="terp_default_Bold_9_Right">[[ formatLang( sum_credit(o.period_id.id, o.journal_id.id)) ]]</para></td>
</tr>
</blockTable>
<blockTable colWidths="83.0,200.0,95.0,92.0,69.0" style="Table_Final_Total_currency">[[ data['form']['amount_currency'] == True or removeParentNode('blockTable') ]]
<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_Right">[[ formatLang( sum_debit(o.period_id.id, o.journal_id.id)) ]]</para></td>
<td><para style="terp_default_Bold_9_Right">[[ formatLang( sum_credit(o.period_id.id, o.journal_id.id)) ]]</para></td>
<td><para style="terp_default_Bold_9_Right"><u>[[formatLang(sum_currency_amount_account(o, data['form'])) ]]</u></para></td>
</tr>
</blockTable>
<para style="terp_default_2">
<font color="white"> </font>
</para>
<section>
<para style="terp_default_8">[[ repeatIn(lines(o.period_id.id,o.journal_id.id),'line') ]]</para>
<blockTable colWidths="83.0,269.0,94.0,92.0" style="Table_Journal_Line_Content">
<blockTable colWidths="83.0,269.0,94.0,92.0" style="Table_Journal_Line_Content">[[ data['form']['amount_currency'] == False or removeParentNode('blockTable') ]]
<tr>
<td><para style="terp_default_9">[[ line['code'] ]]</para></td>
<td><para style="terp_default_9">[[ line['name'] ]]</para></td>
@ -257,6 +302,15 @@
<td><para style="terp_default_Right_9">[[ formatLang(line['credit'])]]</para></td>
</tr>
</blockTable>
<blockTable colWidths="83.0,200.0,95.0,92.0,69.0" style="Table_Journal_Line_Content_currency">[[ data['form']['amount_currency'] == True or removeParentNode('blockTable') ]]
<tr>
<td><para style="terp_default_9">[[ line['code'] ]]</para></td>
<td><para style="terp_default_9">[[ line['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">[[ formatLang(line['amount_currency']) ]] [[ line['currency_code'] or '']]</para></td>
</tr>
</blockTable>
<para style="terp_default_2">
<font color="white"> </font>
</para>