0

I'm having trouble append extra information to the information_block of the DIN5008 template. I inherited the sale.order module like suggested here. I tried override both _compute_l10n_de_template_data functions in the sale.order and the account.move but nothing changes. I can't append nor leave everything empty. If I look for models in the odoo inteface I can see, that my module inherits the sale.order and account.move model. So I don't think I have an error in my __init__.py files. I can also create new fields, but trying to overwrite those functions won't change the output in the report.

Here is my code for the sale.order model:

from odoo import models, fields, _
from odoo.tools import format_date


class SaleOrder(models.Model):
    _inherit = 'sale.order'

    l10n_de_template_data = fields.Binary(compute='_compute_l10n_de_template_data')

    def _compute_l10n_de_template_data(self):
        for record in self:
            record.l10n_de_template_data = data = []
            if record.state in ('draft', 'sent'):
                if record.name:
                    data.append((_("Quotation No."), record.name))
                if record.date_order:
                    data.append((_("Quotation Date"), format_date(self.env, record.date_order)))
                if record.validity_date:
                    data.append((_("Expiration"), format_date(self.env, record.validity_date)))
            else:
                if record.name:
                    data.append((_("Order No."), record.name))
                if record.date_order:
                    data.append((_("Order Date"), format_date(self.env, record.date_order)))
            if record.client_order_ref:
                data.append((_('Customer Reference'), record.client_order_ref))
            if record.user_id:
                data.append((_("Salesperson"), record.user_id.name))
            if record.partner_id:
                data.append((_("Customer"), record.partner_id))

It doesn't matter what I do to _compute_l10n_de_template_data I can't see my changes in an offer or invoice (if I change the function in account.move) Seems like I'm doing something fundamentally wrong.

wjandrea
  • 28,235
  • 9
  • 60
  • 81

1 Answers1

0

You already linked to addon l10n_de_sale in which you can find the definition of _compute_l10n_de_template_data and its DIN 5008 infoblock.

See here.

I ended up adding additional information to the block in the code. After restarting the service it worked well for me.

if record.user_id and record.user_id.mobile:
    data.append((_("Mobile"), record.user_id.mobile))
if record.user_id and record.user_id.email:
    data.append((_("Email"), record.user_id.email))
if record.commitment_date:
    data.append((_("Estimated Delivery"), format_date(self.env, record.commitment_date)))

It shouldn't be forgotten to restart the service to make the changes work.

To have the labels tranlated i generated missing translations in settings and could translate the newly added labels.

tobehn
  • 1
  • 1
  • Is there any way to add to that block without changing the code? I.e. via QWeb inheritance and XPATH only? I've posted my question here: https://stackoverflow.com/questions/74275867/odoo-din5008-append-or-change-information-block-via-xpath – Crazor Nov 01 '22 at 12:21