Refactored layout to add pst to base external layout instead of each of the inherited views.
This commit is contained in:
parent
e0ba8b6008
commit
d16304e57b
2 changed files with 16 additions and 129 deletions
|
|
@ -43,7 +43,7 @@ class TestReportTaxNumbers(TransactionCase):
|
|||
text = self._get_pdf_content('account.report_invoice', self.invoice.id)
|
||||
|
||||
# Check for GST and PST numbers
|
||||
self.assertIn('GST: <span>123456789</span>', text, "GST number not found in invoice")
|
||||
self.assertIn('GST/HST: <span>123456789</span>', text, "GST number not found in invoice")
|
||||
self.assertIn('PST: <span>PST12345</span>', text, "PST number not found in invoice")
|
||||
|
||||
def test_different_layouts(self):
|
||||
|
|
@ -59,7 +59,7 @@ class TestReportTaxNumbers(TransactionCase):
|
|||
text = self._get_pdf_content('account.report_invoice', self.invoice.id)
|
||||
|
||||
# Check for GST and PST numbers
|
||||
self.assertIn('GST: <span>123456789</span>', text,
|
||||
self.assertIn('GST/HST: <span>123456789</span>', text,
|
||||
f"GST number not found in invoice with {layout} layout")
|
||||
self.assertIn('PST: <span>PST12345</span>', text,
|
||||
f"PST number not found in invoice with {layout} layout")
|
||||
|
|
@ -1,136 +1,23 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<template id="l10n_ca_pst_external_layout_standard" inherit_id="web.external_layout_standard">
|
||||
<xpath expr="//li[@t-if='not forced_vat']" position="replace">
|
||||
<li t-if="not forced_vat and o.company_id.country_id.code == 'CA'">
|
||||
<div class="d-flex flex-column">
|
||||
<div t-if="o.company_id.vat">
|
||||
GST: <span t-field="o.company_id.vat"/>
|
||||
</div>
|
||||
<div t-if="o.company_id.l10n_ca_pst">
|
||||
PST: <span t-field="o.company_id.l10n_ca_pst"/>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Main template that will be used by all layouts -->
|
||||
<template id="pst_external_layout" inherit_id="l10n_ca.pst_external_layout">
|
||||
<xpath expr="//li" position="replace">
|
||||
<li t-if="company.account_fiscal_country_id.code == 'CA' and company.vat">
|
||||
GST/HST: <span t-field="company.vat"/>
|
||||
</li>
|
||||
<li t-elif="not forced_vat and o.company_id.vat">
|
||||
<t t-if="o.company_id.country_id.vat_label" t-out="o.company_id.country_id.vat_label" id="inv_tax_id_label"/>
|
||||
<t t-else="">Tax ID</t>: <span t-field="o.company_id.vat"/>
|
||||
<li t-if="company.account_fiscal_country_id.code == 'CA' and company.l10n_ca_pst">
|
||||
PST: <span t-field="company.l10n_ca_pst"/>
|
||||
</li>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<!-- Also inherit other layout styles to maintain consistency -->
|
||||
<template id="l10n_ca_pst_external_layout_boxed" inherit_id="web.external_layout_boxed">
|
||||
<xpath expr="//li[@t-if='not forced_vat']" position="replace">
|
||||
<li t-if="not forced_vat and o.company_id.country_id.code == 'CA'">
|
||||
<div class="d-flex flex-column">
|
||||
<div t-if="o.company_id.vat">
|
||||
GST: <span t-field="o.company_id.vat"/>
|
||||
</div>
|
||||
<div t-if="o.company_id.l10n_ca_pst">
|
||||
PST: <span t-field="o.company_id.l10n_ca_pst"/>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li t-elif="not forced_vat and o.company_id.vat">
|
||||
<t t-if="o.company_id.country_id.vat_label" t-out="o.company_id.country_id.vat_label" id="inv_tax_id_label"/>
|
||||
<t t-else="">Tax ID</t>: <span t-field="o.company_id.vat"/>
|
||||
</li>
|
||||
<!-- Special handling for folder layout since it uses a different structure -->
|
||||
<template id="pst_external_layout_folder" inherit_id="l10n_ca.l10n_ca_external_layout_folder">
|
||||
<xpath expr="//div[hasclass('o_folder_company_info')]" position="after">
|
||||
<div t-if="company.account_fiscal_country_id.code == 'CA' and company.vat" class="o_folder_tax_info">
|
||||
GST/HST: <span t-field="company.vat"/>
|
||||
</div>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<template id="l10n_ca_pst_external_layout_bold" inherit_id="web.external_layout_bold">
|
||||
<xpath expr="//li[@t-if='not forced_vat']" position="replace">
|
||||
<li t-if="not forced_vat and o.company_id.country_id.code == 'CA'">
|
||||
<div class="d-flex flex-column">
|
||||
<div t-if="o.company_id.vat">
|
||||
GST: <span t-field="o.company_id.vat"/>
|
||||
</div>
|
||||
<div t-if="o.company_id.l10n_ca_pst">
|
||||
PST: <span t-field="o.company_id.l10n_ca_pst"/>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li t-elif="not forced_vat and o.company_id.vat">
|
||||
<t t-if="o.company_id.country_id.vat_label" t-out="o.company_id.country_id.vat_label" id="inv_tax_id_label"/>
|
||||
<t t-else="">Tax ID</t>: <span t-field="o.company_id.vat"/>
|
||||
</li>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<template id="l10n_ca_pst_external_layout_striped" inherit_id="web.external_layout_striped">
|
||||
<xpath expr="//li[@t-if='not forced_vat']" position="replace">
|
||||
<li t-if="not forced_vat and o.company_id.country_id.code == 'CA'">
|
||||
<div class="d-flex flex-column">
|
||||
<div t-if="o.company_id.vat">
|
||||
GST: <span t-field="o.company_id.vat"/>
|
||||
</div>
|
||||
<div t-if="o.company_id.l10n_ca_pst">
|
||||
PST: <span t-field="o.company_id.l10n_ca_pst"/>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li t-elif="not forced_vat and o.company_id.vat">
|
||||
<t t-if="o.company_id.country_id.vat_label" t-out="o.company_id.country_id.vat_label" id="inv_tax_id_label"/>
|
||||
<t t-else="">Tax ID</t>: <span t-field="o.company_id.vat"/>
|
||||
</li>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<template id="l10n_ca_pst_external_layout_bubble" inherit_id="web.external_layout_bubble">
|
||||
<xpath expr="//li[@t-if='not forced_vat']" position="replace">
|
||||
<li t-if="not forced_vat and o.company_id.country_id.code == 'CA'">
|
||||
<div class="d-flex flex-column">
|
||||
<div t-if="o.company_id.vat">
|
||||
GST: <span t-field="o.company_id.vat"/>
|
||||
</div>
|
||||
<div t-if="o.company_id.l10n_ca_pst">
|
||||
PST: <span t-field="o.company_id.l10n_ca_pst"/>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li t-elif="not forced_vat and o.company_id.vat">
|
||||
<t t-if="o.company_id.country_id.vat_label" t-out="o.company_id.country_id.vat_label" id="inv_tax_id_label"/>
|
||||
<t t-else="">Tax ID</t>: <span t-field="o.company_id.vat"/>
|
||||
</li>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<template id="l10n_ca_pst_external_layout_wave" inherit_id="web.external_layout_wave">
|
||||
<xpath expr="//li[@t-if='not forced_vat']" position="replace">
|
||||
<li t-if="not forced_vat and o.company_id.country_id.code == 'CA'">
|
||||
<div class="d-flex flex-column">
|
||||
<div t-if="o.company_id.vat">
|
||||
GST: <span t-field="o.company_id.vat"/>
|
||||
</div>
|
||||
<div t-if="o.company_id.l10n_ca_pst">
|
||||
PST: <span t-field="o.company_id.l10n_ca_pst"/>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li t-elif="not forced_vat and o.company_id.vat">
|
||||
<t t-if="o.company_id.country_id.vat_label" t-out="o.company_id.country_id.vat_label" id="inv_tax_id_label"/>
|
||||
<t t-else="">Tax ID</t>: <span t-field="o.company_id.vat"/>
|
||||
</li>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<template id="l10n_ca_pst_external_layout_folder" inherit_id="web.external_layout_folder">
|
||||
<xpath expr="//li[@t-if='not forced_vat']" position="replace">
|
||||
<li t-if="not forced_vat and o.company_id.country_id.code == 'CA'">
|
||||
<div class="d-flex flex-column">
|
||||
<div t-if="o.company_id.vat">
|
||||
GST: <span t-field="o.company_id.vat"/>
|
||||
</div>
|
||||
<div t-if="o.company_id.l10n_ca_pst">
|
||||
PST: <span t-field="o.company_id.l10n_ca_pst"/>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li t-elif="not forced_vat and o.company_id.vat">
|
||||
<t t-if="o.company_id.country_id.vat_label" t-out="o.company_id.country_id.vat_label" id="inv_tax_id_label"/>
|
||||
<t t-else="">Tax ID</t>: <span t-field="o.company_id.vat"/>
|
||||
</li>
|
||||
</xpath>
|
||||
</template>
|
||||
</odoo>
|
||||
</odoo>
|
||||
Loading…
Reference in a new issue