No attribute "footer_used" error when printing draft invoice report

Hi,

I am trying to print a draft invoice report and I get the following error:

AttributeError: "company.company,1" has no attribute "footer_used". Did you mean: 'header_used'?

The company has a footer defined.
Looking at the report template, the export is designed to work with draft invoices, so I don’t understand what’s wrong with “footer_used”.

Any idea?

Thanks,
Fabrice

EDIT:
Here is how the OpenDocument template uses the footer_used method:

<for each="line in invoice.company.footer_used.split('\n')">

Here is what I can found in the code about it:

class Company(ModelSQL, ModelView):
[...]
    footer = fields.Text(
        'Footer',
        help="The text to display on report footers.\n" + _SUBSTITUTION_HELP)
[...]
    @property
    def footer_used(self):
        return Template(self.footer or '').safe_substitute(self._substitutions)

    @property
    def _substitutions(self):
        address = self.party.address_get()
        tax_identifier = self.party.tax_identifier
        return {
            'name': self.party.name,
            'phone': self.party.phone,
            'mobile': self.party.mobile,
            'fax': self.party.fax,
            'email': self.party.email,
            'website': self.party.website,
            'address': (
                ' '.join(address.full_address.splitlines())
                if address else ''),
            'tax_identifier': tax_identifier.code if tax_identifier else '',
            }


Probably you have some syntax error on your footer template which causes and error but is its hidden inside the python property.

With no footer (empty), the invoice is correctly generated.
Adding a single character to it (tested with a single ‘f’ or ‘toto’ or ${name}…) produces the error.
Same with header.

I have these versions installed:

  • trytond v7.2.3
  • account_invoice v7.2.2
  • company v7.2.1

Is anybody able to reproduce?

I’ve just tried adding some text to the company headers on https://demo7.2.tryton.org/ and it seems to be working correctly. Have you got any custom modules activated?

No custom module:

Nom,Version,État (chaîne)
account,7.2.3,Activé
account_asset,7.2.1,Activé
account_fr,7.2.0,Activé
account_invoice,7.2.2,Activé
account_payment,7.2.1,Activé
account_payment_sepa,7.2.1,Activé
account_payment_sepa_cfonb,7.2.0,Activé
account_product,7.2.0,Activé
account_statement,7.2.2,Activé
account_statement_ofx,7.2.0,Activé
account_statement_rule,7.2.2,Activé
bank,7.2.1,Activé
company,7.2.1,Activé
company_work_time,7.2.0,Activé
country,7.2.1,Activé
currency,7.2.2,Activé
ir,Activé
party,7.2.1,Activé
party_siret,7.2.1,Activé
product,7.2.1,Activé
res,Activé
timesheet,7.2.1,Activé

1 Like

FYI "footer_used" KeyError/AttributeError when printing an invoice report (#13366) · Issues · Tryton / Tryton · GitLab