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)
|
text = self._get_pdf_content('account.report_invoice', self.invoice.id)
|
||||||
|
|
||||||
# Check for GST and PST numbers
|
# 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")
|
self.assertIn('PST: <span>PST12345</span>', text, "PST number not found in invoice")
|
||||||
|
|
||||||
def test_different_layouts(self):
|
def test_different_layouts(self):
|
||||||
|
|
@ -59,7 +59,7 @@ class TestReportTaxNumbers(TransactionCase):
|
||||||
text = self._get_pdf_content('account.report_invoice', self.invoice.id)
|
text = self._get_pdf_content('account.report_invoice', self.invoice.id)
|
||||||
|
|
||||||
# Check for GST and PST numbers
|
# 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")
|
f"GST number not found in invoice with {layout} layout")
|
||||||
self.assertIn('PST: <span>PST12345</span>', text,
|
self.assertIn('PST: <span>PST12345</span>', text,
|
||||||
f"PST number not found in invoice with {layout} layout")
|
f"PST number not found in invoice with {layout} layout")
|
||||||
|
|
@ -1,136 +1,23 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<odoo>
|
<odoo>
|
||||||
<template id="l10n_ca_pst_external_layout_standard" inherit_id="web.external_layout_standard">
|
<!-- Main template that will be used by all layouts -->
|
||||||
<xpath expr="//li[@t-if='not forced_vat']" position="replace">
|
<template id="pst_external_layout" inherit_id="l10n_ca.pst_external_layout">
|
||||||
<li t-if="not forced_vat and o.company_id.country_id.code == 'CA'">
|
<xpath expr="//li" position="replace">
|
||||||
<div class="d-flex flex-column">
|
<li t-if="company.account_fiscal_country_id.code == 'CA' and company.vat">
|
||||||
<div t-if="o.company_id.vat">
|
GST/HST: <span t-field="company.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>
|
||||||
<li t-elif="not forced_vat and o.company_id.vat">
|
<li t-if="company.account_fiscal_country_id.code == 'CA' and company.l10n_ca_pst">
|
||||||
<t t-if="o.company_id.country_id.vat_label" t-out="o.company_id.country_id.vat_label" id="inv_tax_id_label"/>
|
PST: <span t-field="company.l10n_ca_pst"/>
|
||||||
<t t-else="">Tax ID</t>: <span t-field="o.company_id.vat"/>
|
|
||||||
</li>
|
</li>
|
||||||
</xpath>
|
</xpath>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<!-- Also inherit other layout styles to maintain consistency -->
|
<!-- Special handling for folder layout since it uses a different structure -->
|
||||||
<template id="l10n_ca_pst_external_layout_boxed" inherit_id="web.external_layout_boxed">
|
<template id="pst_external_layout_folder" inherit_id="l10n_ca.l10n_ca_external_layout_folder">
|
||||||
<xpath expr="//li[@t-if='not forced_vat']" position="replace">
|
<xpath expr="//div[hasclass('o_folder_company_info')]" position="after">
|
||||||
<li t-if="not forced_vat and o.company_id.country_id.code == 'CA'">
|
<div t-if="company.account_fiscal_country_id.code == 'CA' and company.vat" class="o_folder_tax_info">
|
||||||
<div class="d-flex flex-column">
|
GST/HST: <span t-field="company.vat"/>
|
||||||
<div t-if="o.company_id.vat">
|
</div>
|
||||||
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>
|
</xpath>
|
||||||
</template>
|
</template>
|
||||||
|
</odoo>
|
||||||
<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>
|
|
||||||
Loading…
Reference in a new issue