Я использую Odoo v14. Я добавил новое поле в счет-фактуру сразу после 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>
Пока здесь все работает нормально, но когда я меняю раскладку на Din 5008, поле больше не отображается, похоже, это называется другой шаблон. Этот:
<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>
Как настроить это, чтобы включить сюда и new_field?
Раздел informations
счета-фактуры не отображается в отчете din5008
, вместо него добавляется новый информационный блок и получает его значения из метода _compute_l10n_de_template_data.
Чтобы показать новое поле внутри информационного блока, вы можете просто переопределить этот метод и добавить описание поля и значение поля, как показано ниже:
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))