Dori
Dori

Reputation: 396

How to custom or update Invoice Layout Din 5008 Odoo

Im using Odoo v14. I've add new field in invoice, directly after invoice_date.

<template id="account_invoice_report_add_field" inherit_id="account.report_invoice_document">
    <xpath expr="//div[@t-if='o.invoice_date']" position="after">
           <div t-field="o.new_field"/>
    </xpath>
</template>

Until here everything works OK, but when I change the layout to Din 5008. The field is not showing anymore, looks like that is called another template. This one:

 <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.invoice_user_id.sudo().lang if o.move_type in ('in_invoice', 'in_refund') else o.partner_id.lang"/>
                <t t-set="print_with_payments" t-value="True"/>
            </t>
        </t>
    </template>

How can custom this one, to include new_field here as well?

Upvotes: 1

Views: 771

Answers (1)

Kenly
Kenly

Reputation: 26688

The invoice informations div is not shown in the din5008 report, unstead a new information block is added and get its values from _compute_l10n_de_template_data method.

To show the new field inside the information block, you can simply override that method and add the field description and field value like the following:

class AccountMove(models.Model):
    _inherit = 'account.move'

    new_field = fields.Char()

    def _compute_l10n_de_template_data(self):
        super(AccountMove, self)._compute_l10n_de_template_data()
        for record in self:
            if record.new_field:
                record.l10n_de_template_data.append((_("New field"), record.new_field))

Upvotes: 1

Related Questions