Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
1 Balas
6170 Tampilan

Hi there,

I need to customise the invoice format to provide an option to print the invoice in an alternative format. I do not want to replace the existing invoice report just use it as a base for another report. Is there a way to do this with inheritance where it doesn't replace the original report?

If I can't use inheritance I will have to copy the template of the existing report and give it a new id and make the changes in that copied template rather than simply overriding. That is the extent of my knowledge right now.

thanks 

Avatar
Buang
Jawaban Terbai

Yes, this is possible. Examples form account module:

<report
id="account_invoices"
model="account.invoice"
string="Invoices"
report_type="qweb-pdf"
name="account.report_invoice_with_payments"
file="account.report_invoice_with_payments"
attachment="(object.state in ('open','in_payment','paid')) and ('INV'+(object.number or '').replace('/','')+'.pdf')"
print_report_name="(object._get_report_base_filename())"
groups="account.group_account_invoice"
/>

<report
id="account_invoices_without_payment"
model="account.invoice"
string="Invoices without Payment"
report_type="qweb-pdf"
name="account.report_invoice"
file="account.report_invoice"
attachment="(object.state in ('open','in_payment','paid')) and ('INV'+(object.number or '').replace('/','')+'.pdf')"
print_report_name="(object._get_report_base_filename())"
/>

<template id="report_invoice">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="o">
<t t-set="lang" t-value="o.user_id.lang if o.type in ('in_invoice', 'in_refund') else o.partner_id.lang"/>
<t t-call="account.report_invoice_document" t-lang="lang"/>
</t>
</t>
</template>

<template id="report_invoice_with_payments">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="o">
<t t-set="lang" t-value="o.user_id.lang if o.type in ('in_invoice', 'in_refund') else o.partner_id.lang"/>
<t t-call="account.report_invoice_document_with_payments" t-lang="lang"/>
</t>
</t>
</template>


<template id="report_invoice_document_with_payments" inherit_id="account.report_invoice_document" primary="True">
<xpath expr="//div[@id='total']/div/table" position="inside">
<t t-set="payments_vals" t-value="o._get_payments_vals()"/>
<t t-foreach="payments_vals" t-as="payment_vals">
<tr>
<td>
<i class="oe_form_field text-right oe_payment_label">Paid on <t t-esc="payment_vals['date']"/></i>
</td>
<td class="text-right">
<span t-esc="payment_vals['amount']" t-options='{"widget": "monetary", "display_currency": o.currency_id}'/>
</td>
</tr>
</t>
<t t-if="len(payments_vals) > 0">
<tr class="border-black">
<td><strong>Amount Due</strong></td>
<td class="text-right">
<span t-field="o.residual"/>
</td>
</tr>
</t>
</xpath>
</template>



Avatar
Buang