Skip to content

Commit

Permalink
FIX l10n_it_withholding_tax when other localizations are installed
Browse files Browse the repository at this point in the history
Steps:

 - Install l10n_it_withholding_tax
 - install l10n_ar
 - with AR company, print invoice PDF

Get
ValueError: Element '<t t-call="account.document_tax_totals">' cannot be located in parent view
  • Loading branch information
eLBati committed Jan 29, 2024
1 parent e8ff597 commit 11de9ac
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
6 changes: 6 additions & 0 deletions l10n_it_withholding_tax/models/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,12 @@ def action_register_payment(self):
res.update({"context": ctx})
return res

def _get_name_invoice_report(self):
self.ensure_one()

Check warning on line 550 in l10n_it_withholding_tax/models/account.py

View check run for this annotation

Codecov / codecov/patch

l10n_it_withholding_tax/models/account.py#L550

Added line #L550 was not covered by tests
if self.company_id.account_fiscal_country_id.code == 'IT':
return 'l10n_it_withholding_tax.print_withholding_tax'
return super()._get_name_invoice_report()

Check warning on line 553 in l10n_it_withholding_tax/models/account.py

View check run for this annotation

Codecov / codecov/patch

l10n_it_withholding_tax/models/account.py#L552-L553

Added lines #L552 - L553 were not covered by tests


class AccountMoveLine(models.Model):
_inherit = "account.move.line"
Expand Down
15 changes: 14 additions & 1 deletion l10n_it_withholding_tax/views/report_invoice.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,21 @@
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-->
<odoo>
<template id="report_invoice" inherit_id="account.report_invoice">
<xpath expr='//t[@t-call="account.report_invoice_document"]' position="after">
<t t-if="o._get_name_invoice_report() == 'l10n_it_withholding_tax.print_withholding_tax'"
t-call="l10n_it_withholding_tax.print_withholding_tax" t-lang="lang"/>
</xpath>
</template>

<template id="report_invoice_with_payments" inherit_id="account.report_invoice_with_payments">
<xpath expr='//t[@t-call="account.report_invoice_document"]' position="after">
<t t-if="o._get_name_invoice_report() == 'l10n_it_withholding_tax.print_withholding_tax'"
t-call="l10n_it_withholding_tax.print_withholding_tax" t-lang="lang"/>
</xpath>
</template>

<template id="print_withholding_tax" inherit_id="account.report_invoice_document">
<template id="print_withholding_tax" inherit_id="account.report_invoice_document" primary="True">
<xpath
expr="//table[@name='invoice_line_table']/thead/tr/th[6]"
position="after"
Expand Down

0 comments on commit 11de9ac

Please sign in to comment.