[IMP] account: Improved partner and general ledger reports for account currency
bzr revid: pso@tinyerp.com-20101119094758-n54crq4lq41he265
This commit is contained in:
@@ -191,17 +191,19 @@ class general_ledger(report_sxw.rml_parse, common_report_header):
|
||||
sql = """
|
||||
SELECT 0 AS lid, '' AS ldate, '' AS lcode, COALESCE(SUM(l.amount_currency),0.0) AS amount_currency, '' AS lref, 'Initial Balance' AS lname, COALESCE(SUM(l.debit),0.0) AS debit, COALESCE(SUM(l.credit),0.0) AS credit, '' AS lperiod_id, '' AS lpartner_id,
|
||||
'' AS move_name, '' AS mmove_id,
|
||||
'' AS currency_code,
|
||||
NULL AS currency_id,
|
||||
c.symbol AS currency_code,
|
||||
'' AS currency_id,
|
||||
'' AS invoice_id, '' AS invoice_type, '' AS invoice_number,
|
||||
'' AS partner_name
|
||||
FROM account_move_line l
|
||||
LEFT JOIN account_move m on (l.move_id=m.id)
|
||||
LEFT JOIN account_account ac on (l.account_id=ac.id)
|
||||
LEFT JOIN res_currency c on (l.currency_id=c.id)
|
||||
LEFT JOIN res_partner p on (l.partner_id=p.id)
|
||||
LEFT JOIN account_invoice i on (m.id =i.move_id)
|
||||
JOIN account_journal j on (l.journal_id=j.id)
|
||||
WHERE %s AND m.state IN %s AND l.account_id = %%s
|
||||
WHERE %s AND m.state IN %s AND l.account_id = %%s
|
||||
group by c.symbol
|
||||
""" %(self.init_query, tuple(move_state))
|
||||
self.cr.execute(sql, (account.id,))
|
||||
res_init = self.cr.dictfetchall()
|
||||
|
||||
@@ -327,7 +327,7 @@
|
||||
<td><para style="P4_content">[[ formatLang(line['debit'], digits=get_digits(dp='Account')) ]]</para></td>
|
||||
<td><para style="P4_content">[[ formatLang(line['credit'], digits=get_digits(dp='Account')) ]]</para></td>
|
||||
<td><para style="P4_content">[[ formatLang(line['progress'], digits=get_digits(dp='Account')) ]] [[ company.currency_id.symbol ]]</para></td>
|
||||
<td><para style="P4_content"><font>[[ (line.has_key('currency_id') and line['currency_id']==None or line['amount_currency']==None) and removeParentNode('font') ]] [[ formatLang(line['amount_currency'])]] [[ line['currency_code'] or '']]</font></para></td>
|
||||
<td><para style="P4_content"><font>[[ (o.currency_id and formatLang(line['amount_currency'])) or removeParentNode('font') ]] [[ line['currency_code'] or '']] </font></para></td>
|
||||
</tr>
|
||||
</blockTable>
|
||||
|
||||
|
||||
@@ -50,6 +50,7 @@ class third_party_ledger(report_sxw.rml_parse, common_report_header):
|
||||
'display_initial_balance':self._display_initial_balance,
|
||||
'display_currency':self._display_currency,
|
||||
'get_target_move': self._get_target_move,
|
||||
'sum_currency_amount_account': self._sum_currency_amount_account
|
||||
})
|
||||
|
||||
def set_context(self, objects, data, ids, report_type=None):
|
||||
@@ -178,7 +179,8 @@ class third_party_ledger(report_sxw.rml_parse, common_report_header):
|
||||
" " + RECONCILE_TAG + " "\
|
||||
"AND " + self.init_query + " ",
|
||||
(partner.id, tuple(move_state), tuple(self.account_ids)))
|
||||
return self.cr.fetchall()
|
||||
res = self.cr.fetchall()
|
||||
return res
|
||||
|
||||
def _sum_debit_partner(self, partner):
|
||||
move_state = ['draft','posted']
|
||||
@@ -385,16 +387,27 @@ class third_party_ledger(report_sxw.rml_parse, common_report_header):
|
||||
return 'Receivable and Payable Accounts'
|
||||
return ''
|
||||
|
||||
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,))
|
||||
# def _set_get_account_currency_code(self, account_id):
|
||||
# self.cr.execute("SELECT c.symbol 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):
|
||||
# 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
|
||||
return total[0] or 0.0
|
||||
# if self.amount_currency:
|
||||
# return_field = total[0] + self.amount_currency
|
||||
# return return_field
|
||||
# else:
|
||||
# currency_total = self.tot_currency = 0.0
|
||||
# return currency_total
|
||||
|
||||
def _display_initial_balance(self, data):
|
||||
if self.initial_balance:
|
||||
|
||||
@@ -327,7 +327,8 @@
|
||||
<paraStyle name="Table index 1" rightIndent="0.0" leftIndent="0.0" fontName="Helvetica"/>
|
||||
<paraStyle name="Table" fontName="Helvetica" fontSize="10.0" leading="13" spaceBefore="6.0" spaceAfter="6.0"/>
|
||||
<paraStyle name="Table index heading" rightIndent="0.0" leftIndent="0.0" fontName="Helvetica-Bold" fontSize="16.0" leading="20" spaceBefore="12.0" spaceAfter="6.0"/>
|
||||
<paraStyle name="terp_default_Right_1" fontName="Helvetica" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
|
||||
<paraStyle name="terp_default_Right_1" fontName="Helvetica" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
|
||||
<paraStyle name="P9b" fontName="Helvetica-Bold" fontSize="8.5" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
|
||||
<images/>
|
||||
</stylesheet>
|
||||
<story>
|
||||
@@ -656,7 +657,7 @@
|
||||
<para style="terp_default_Right_9">[[ formatLang(get_intial_balance(p)[0][2]) ]] [[ company.currency_id.symbol ]]</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="terp_default_Right_9"></para>
|
||||
<para style="terp_default_Right_9">[[ p.property_account_receivable.currency_id and formatLang(sum_currency_amount_account(p.property_account_receivable), digits=get_digits(dp='Account')) + p.property_account_receivable.currency_id.symbol or '' ]]</para>
|
||||
</td>
|
||||
</tr>
|
||||
</blockTable>
|
||||
@@ -689,7 +690,7 @@
|
||||
<para style="terp_default_Right_9">[[ formatLang((line['progress'])) ]] [[ company.currency_id.symbol ]]</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="terp_default_Right_9"><font>[[ (line['currency_id']==None or line['amount_currency']==None) and removeParentNode('font') ]] [[ formatLang(line['amount_currency'] ) ]] [[ line['currency_code'] or '' ]]</font></para>
|
||||
<para style="terp_default_Right_9"><font>[[ (p.property_account_receivable.currency_id and formatLang(line['amount_currency'])) or removeParentNode('font') ]] [[ line['currency_code'] or '']] </font></para>
|
||||
</td>
|
||||
</tr>
|
||||
</blockTable>
|
||||
|
||||
Reference in New Issue
Block a user