[FIX] fixed report translation and translate overdue report into partner's lang
bzr revid: sle@openerp.com-20140403143235-mpw30fq4j2nyov6x
This commit is contained in:
parent
55090e56db
commit
4975d2b9dc
|
@ -1,112 +1,116 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<template id="account.report_overdue">
|
||||
<t t-call="report.html_container">
|
||||
<t t-foreach="docs" t-as="partner">
|
||||
<t t-call="report.external_layout">
|
||||
<div class="page">
|
||||
<div class="row">
|
||||
<div class="col-xs-4 col-xs-offset-6">
|
||||
<span t-field="partner.name"/><br/>
|
||||
<span t-raw="addresses[partner.id].replace('\n\n', '\n').replace('\n', '<br>')"/>
|
||||
<span t-field="partner.vat"/>
|
||||
</div>
|
||||
</div>
|
||||
<template id="account.report_overdue_document">
|
||||
<t t-call="report.external_layout">
|
||||
<div class="page">
|
||||
<div class="row">
|
||||
<div class="col-xs-4 col-xs-offset-6">
|
||||
<span t-field="o.name"/><br/>
|
||||
<span t-raw="addresses[o.id].replace('\n\n', '\n').replace('\n', '<br>')"/>
|
||||
<span t-field="o.vat"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
Document: Customer account statement<br/>
|
||||
Date: <span t-esc="formatLang(time.strftime('%Y-%m-%d'), date=True)"/><br/>
|
||||
Customer ref: <span t-field="partner.ref"/>
|
||||
</p>
|
||||
<p>
|
||||
Document: Customer account statement<br/>
|
||||
Date: <span t-esc="formatLang(time.strftime('%Y-%m-%d'), date=True)"/><br/>
|
||||
Customer ref: <span t-field="o.ref"/>
|
||||
</p>
|
||||
|
||||
<p t-if="getLines(partner)">
|
||||
<t t-foreach="message(partner, res_company)" t-as="messageline">
|
||||
<span t-esc="messageline"/>
|
||||
<p t-if="getLines(o)">
|
||||
<t t-foreach="message(o, res_company)" t-as="messageline">
|
||||
<span t-esc="messageline"/>
|
||||
</t>
|
||||
</p>
|
||||
|
||||
<table class="table table-condensed" t-if="getLines(o)">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Date</th>
|
||||
<th>Description</th>
|
||||
<th class="text-center">Ref</th>
|
||||
<th class="text-center">Maturity Date</th>
|
||||
<th class="text-right">Due</th>
|
||||
<th class="text-right">Paid</th>
|
||||
<th class="text-right">Maturity</th>
|
||||
<th class="text-center">Li.</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tr t-foreach="getLines(o)" t-as="line">
|
||||
<td>
|
||||
<span t-field="line.date"/>
|
||||
</td>
|
||||
<td>
|
||||
<span t-field="line.name"/>
|
||||
</td>
|
||||
<td>
|
||||
<span t-field="line.ref"/>
|
||||
</td>
|
||||
<td>
|
||||
<span t-field="line.date_maturity"/>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<t t-if="line.account_id.type == 'receivable'">
|
||||
<span t-esc="formatLang(line.debit)"/>
|
||||
</t>
|
||||
</p>
|
||||
<t t-if="line.account_id.type == 'payable'">
|
||||
<span t-esc="formatLang(line['credit'] * -1)"/>
|
||||
</t>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<t t-if="line.account_id.type == 'receivable'">
|
||||
<span t-esc="formatLang(line.credit)"/>
|
||||
</t>
|
||||
<t t-if="line.account_id.type == 'payable'">
|
||||
<span t-esc="formatLang(line.debit * -1)"/>
|
||||
</t>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<t t-if="time.strftime('%Y-%m-%d') > line['date_maturity']">
|
||||
<span t-esc="formatLang(line.debit - line.credit, currency_obj=res_company.currency_id)"/>
|
||||
</t>
|
||||
</td>
|
||||
<td>
|
||||
<span t-if="line.blocked">x</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3"></td>
|
||||
<td><strong>Sub-Total :</strong></td>
|
||||
<td class="text-right"><span t-esc="formatLang(due[o.id])"/></td>
|
||||
<td class="text-right"><span t-esc="formatLang(paid[o.id])"/></td>
|
||||
<td class="text-right"><span t-esc="formatLang(mat[o.id])"/></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3"></td>
|
||||
<td><strong>Balance :</strong></td>
|
||||
<td class="text-right">
|
||||
<span t-esc="formatLang(due[o.id] - paid[o.id], currency_obj=res_company.currency_id)"/>
|
||||
</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table class="table table-condensed" t-if="getLines(partner)">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Date</th>
|
||||
<th>Description</th>
|
||||
<th class="text-center">Ref</th>
|
||||
<th class="text-center">Maturity Date</th>
|
||||
<th class="text-right">Due</th>
|
||||
<th class="text-right">Paid</th>
|
||||
<th class="text-right">Maturity</th>
|
||||
<th class="text-center">Li.</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tr t-foreach="getLines(partner)" t-as="line">
|
||||
<td>
|
||||
<span t-field="line.date"/>
|
||||
</td>
|
||||
<td>
|
||||
<span t-field="line.name"/>
|
||||
</td>
|
||||
<td>
|
||||
<span t-field="line.ref"/>
|
||||
</td>
|
||||
<td>
|
||||
<span t-field="line.date_maturity"/>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<t t-if="line.account_id.type == 'receivable'">
|
||||
<span t-esc="formatLang(line.debit)"/>
|
||||
</t>
|
||||
<t t-if="line.account_id.type == 'payable'">
|
||||
<span t-esc="formatLang(line['credit'] * -1)"/>
|
||||
</t>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<t t-if="line.account_id.type == 'receivable'">
|
||||
<span t-esc="formatLang(line.credit)"/>
|
||||
</t>
|
||||
<t t-if="line.account_id.type == 'payable'">
|
||||
<span t-esc="formatLang(line.debit * -1)"/>
|
||||
</t>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<t t-if="time.strftime('%Y-%m-%d') > line['date_maturity']">
|
||||
<span t-esc="formatLang(line.debit - line.credit, currency_obj=res_company.currency_id)"/>
|
||||
</t>
|
||||
</td>
|
||||
<td>
|
||||
<span t-if="line.blocked">x</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3"></td>
|
||||
<td><strong>Sub-Total :</strong></td>
|
||||
<td class="text-right"><span t-esc="formatLang(due[partner.id])"/></td>
|
||||
<td class="text-right"><span t-esc="formatLang(paid[partner.id])"/></td>
|
||||
<td class="text-right"><span t-esc="formatLang(mat[partner.id])"/></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3"></td>
|
||||
<td><strong>Balance :</strong></td>
|
||||
<td class="text-right">
|
||||
<span t-esc="formatLang(due[partner.id] - paid[partner.id], currency_obj=res_company.currency_id)"/>
|
||||
</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
<p t-if="getLines(o)">
|
||||
Total amount due:
|
||||
<span t-esc="formatLang((reduce(lambda x, y: x + (y['debit'] - y['credit']), getLines(o), 0)), currency_obj=res_company.currency_id)"/>
|
||||
</p>
|
||||
|
||||
<p t-if="getLines(partner)">
|
||||
Total amount due:
|
||||
<span t-esc="formatLang((reduce(lambda x, y: x + (y['debit'] - y['credit']), getLines(partner), 0)), currency_obj=res_company.currency_id)"/>
|
||||
</p>
|
||||
<p t-if="not getLines(o)">
|
||||
<strong>There is nothing due with this customer.</strong>
|
||||
</p>
|
||||
</div>
|
||||
</t>
|
||||
</template>
|
||||
|
||||
<p t-if="not getLines(partner)">
|
||||
<strong>There is nothing due with this customer.</strong>
|
||||
</p>
|
||||
</div>
|
||||
</t>
|
||||
<template id="report_overdue">
|
||||
<t t-call="report.html_container">
|
||||
<t t-foreach="doc_ids" t-as="doc_id">
|
||||
<t t-raw="render_doc(doc_id, doc_model, 'account.report_overdue_document')"/>
|
||||
</t>
|
||||
</t>
|
||||
</template>
|
||||
|
|
|
@ -57,4 +57,9 @@ class AbstractReport(osv.AbstractModel):
|
|||
# rendering environment
|
||||
docargs = wrapped_report.localcontext
|
||||
docargs['docs'] = docargs.get('objects')
|
||||
|
||||
# Used in template translating (see render_doc method from report model)
|
||||
docargs['doc_ids'] = context['active_ids']
|
||||
docargs['doc_model'] = model
|
||||
|
||||
return self.pool['report'].render(cr, uid, [], self._template, docargs, context=context)
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
from openerp.osv import osv
|
||||
from openerp.tools import config
|
||||
from openerp.tools.translate import _
|
||||
from openerp.addons.web.http import request
|
||||
|
||||
import os
|
||||
import time
|
||||
|
@ -121,18 +122,28 @@ class Report(osv.Model):
|
|||
if ctx.get('translatable') is True:
|
||||
qcontext['o'] = doc
|
||||
else:
|
||||
ctx['lang'] = doc.partner_id.lang
|
||||
qcontext['o'] = self.pool[model].browse(cr, uid, doc_id, context=ctx)
|
||||
# Guessing the lang we want to translate the doc into
|
||||
newlang = None
|
||||
if hasattr(doc, 'partner_id'):
|
||||
newlang = doc.partner_id.lang
|
||||
elif hasattr(doc, 'lang'):
|
||||
newlang = doc.lang
|
||||
if newlang:
|
||||
ctx['lang'] = newlang
|
||||
qcontext['o'] = self.pool[model].browse(cr, uid, doc_id, context=ctx)
|
||||
return view_obj.render(cr, uid, template, qcontext, context=ctx)
|
||||
|
||||
user = self.pool['res.users'].browse(cr, uid, uid)
|
||||
website = None
|
||||
if request and hasattr(request, 'website'):
|
||||
website = request.website
|
||||
values.update({
|
||||
'time': time,
|
||||
'render_doc': render_doc,
|
||||
'editable': True, # Will active inherit_branding
|
||||
'user': user,
|
||||
'res_company': user.company_id,
|
||||
'website': False, # Will be overidden by ir.ui.view if the request has website enabled
|
||||
'website': website,
|
||||
})
|
||||
return view_obj.render(cr, uid, template, values, context=context)
|
||||
|
||||
|
@ -325,7 +336,6 @@ class Report(osv.Model):
|
|||
|
||||
# Passing the cookie to wkhtmltopdf in order to resolve URL.
|
||||
try:
|
||||
from openerp.addons.web.http import request
|
||||
if request:
|
||||
command_args.extend(['--cookie', 'session_id', request.session.sid])
|
||||
except AttributeError:
|
||||
|
|
|
@ -72,15 +72,24 @@
|
|||
</xpath>
|
||||
|
||||
<xpath expr='//body[@class="container"]/div[@id="wrapwrap"]' position="before">
|
||||
<t t-set="languages" t-value="website.get_languages() if website else list()"/>
|
||||
<ul class="list-inline js_language_selector mt16" t-if="(len(languages) > 1 or editable)">
|
||||
<li t-foreach="languages" t-as="lg">
|
||||
<a t-att-href="url_for('', lang=lg[0]) + '?' + keep_query()"
|
||||
t-att-data-default-lang="editable and 'true' if lg[0] == website.default_lang_code else None">
|
||||
<t t-esc="lg[1].split('/').pop()"/>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<t t-set="languages" t-value="website.get_languages() if website else None"/>
|
||||
<t t-if="languages">
|
||||
<ul class="list-inline js_language_selector mt16" t-if="(len(languages) > 1 or editable)">
|
||||
<li t-foreach="languages" t-as="lg">
|
||||
<a t-att-href="url_for('', lang=lg[0]) + '?' + keep_query()"
|
||||
t-att-data-default-lang="editable and 'true' if lg[0] == website.default_lang_code else None">
|
||||
<t t-esc="lg[1].split('/').pop()"/>
|
||||
</a>
|
||||
</li>
|
||||
<li groups="base.group_website_publisher">
|
||||
<t t-set="url_return" t-value="url_for('', '[lang]') + '?' + keep_query()"/>
|
||||
<a t-attf-href="/web#action=base.action_view_base_language_install&website_id=#{website.id}&url_return=#{url_return}">
|
||||
<i class="fa fa-plus-circle"/>
|
||||
Add a language...
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</t>
|
||||
</xpath>
|
||||
</template>
|
||||
</data>
|
||||
|
|
Loading…
Reference in New Issue