Skip to content

Commit e19efd2

Browse files
committed
[IMP] web, l10n_*, *: make document title dynamic
*: account, sale, purchase On the new layouts we need to be able to dynamically move the title of the report depending on the selected layout. This commit sets up the main report templates to use the variable `layout_document_title` instead of their h2. Thus this requires to add support for this variable on the existing layout and to adapt the xpath that were targeting the h2 element. task-3628644 Part-of: odoo#169512 Related: odoo/enterprise#64811 Signed-off-by: Quentin De Paoli (qdp) <qdp@odoo.com>
1 parent d999f2e commit e19efd2

13 files changed

Lines changed: 34 additions & 27 deletions

File tree

addons/account/views/report_invoice.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
</div>
5151
<div class="clearfix">
5252
<div class="page mb-4">
53-
<h2>
53+
<t t-set="layout_document_title">
5454
<span t-if="not proforma"></span>
5555
<span t-else="">PROFORMA</span>
5656
<span t-if="o.move_type == 'out_invoice' and o.state == 'posted'">Invoice</span>
@@ -62,7 +62,7 @@
6262
<span t-elif="o.move_type == 'in_refund'">Vendor Credit Note</span>
6363
<span t-elif="o.move_type == 'in_invoice'">Vendor Bill</span>
6464
<span t-if="o.name != '/'" t-field="o.name">INV/2023/0001</span>
65-
</h2>
65+
</t>
6666
<div class="oe_structure"></div>
6767
<div id="informations" class="row mb-4">
6868
<div class="col" t-if="o.invoice_date" name="invoice_date">

addons/l10n_ae/views/report_invoice_templates.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</b>
1010
</p>
1111
</xpath>
12-
<xpath expr="//h2/span" position="before">
12+
<xpath expr="//t[@t-set='layout_document_title']/span" position="before">
1313
<span t-if="o.company_id.country_id.code == 'AE' and o.move_type in ['out_invoice', 'out_refund']">TAX
1414
</span>
1515
</xpath>

addons/l10n_ar/views/report_invoice.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
</xpath>
113113

114114
<!-- remove default document title -->
115-
<h2 position="replace"/>
115+
<xpath expr="//t[@t-set='layout_document_title']" position="replace"/>
116116

117117
<!-- NCM column for fiscal bond -->
118118
<th name="th_description" position="after">

addons/l10n_au/views/report_invoice.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<odoo>
33
<template id="report_invoice_document" inherit_id="account.report_invoice_document" primary="True">
4-
<xpath expr="//div[hasclass('page')]/h2" position="replace">
5-
<h2>
4+
<xpath expr="//div[hasclass('page')]/t[@t-set='layout_document_title']" position="replace">
5+
<t t-set="layout_document_title">
66
<span t-if="o.move_type == 'out_invoice' and o.state == 'posted'">Tax Invoice</span>
77
<span t-elif="o.move_type == 'out_invoice' and o.state == 'draft'">Draft Tax Invoice</span>
88
<span t-elif="o.move_type == 'out_invoice' and o.state == 'cancel'">Cancelled Tax Invoice</span>
@@ -12,7 +12,7 @@
1212
<span t-elif="o.move_type == 'in_refund'">Tax Vendor Credit Note</span>
1313
<span t-elif="o.move_type == 'in_invoice'">Tax Vendor Bill</span>
1414
<span t-if="o.name != '/'" t-field="o.name"/>
15-
</h2>
15+
</t>
1616
</xpath>
1717
</template>
1818

addons/l10n_cl/views/report_invoice.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@
150150
<div name="no_shipping"/>
151151
</xpath>
152152

153-
<xpath expr="//h2" position="replace"/>
153+
<xpath expr="//t[@t-set='layout_document_title']" position="replace"/>
154154

155155
<t t-set="current_subtotal" t-value="current_subtotal + line.price_subtotal" position="before">
156156
<t t-set="line_amounts" t-value="line._l10n_cl_get_line_amounts()"/>

addons/l10n_in/views/report_invoice.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@
4848
</t>
4949
</xpath>
5050

51-
<xpath expr="//h2" position="replace">
52-
<h2>
51+
<xpath expr="//t[@t-set='layout_document_title']" position="replace">
52+
<t t-set="layout_document_title">
5353
<span t-if="o.move_type == 'out_invoice' and o.state == 'posted'" t-field="o.journal_id.name"/>
5454
<span t-elif="o.move_type == 'out_invoice' and o.state == 'draft'">Draft <span t-field="o.journal_id.name"/></span>
5555
<span t-elif="o.move_type == 'out_invoice' and o.state == 'cancel'">Cancelled <span t-field="o.journal_id.name"/></span>
@@ -59,7 +59,7 @@
5959
<span t-elif="o.move_type == 'in_refund'">Vendor Credit Note</span>
6060
<span t-elif="o.move_type == 'in_invoice'">Vendor Bill</span>
6161
<span t-if="o.name != '/'" t-field="o.name"/>
62-
</h2>
62+
</t>
6363
</xpath>
6464

6565
<xpath expr="//div[@id='payment_term']" position="before">

addons/l10n_mu_account/views/report_invoice.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<xpath expr="//div[@id='informations']" position="before">
55
<t t-set="forced_vat" t-value="o.company_id.vat"/>
66
</xpath>
7-
<xpath expr="//div[hasclass('page')]/h2" position="replace">
8-
<h2>
7+
<xpath expr="//div[hasclass('page')]/t[@t-set='layout_document_title']" position="replace">
8+
<t t-set="layout_document_title">
99
<span t-if="o.move_type == 'out_invoice' and o.state == 'posted'">VAT Invoice</span>
1010
<span t-elif="o.move_type == 'out_invoice' and o.state == 'draft'">Draft VAT Invoice</span>
1111
<span t-elif="o.move_type == 'out_invoice' and o.state == 'cancel'">Cancelled VAT Invoice</span>
@@ -15,7 +15,7 @@
1515
<span t-elif="o.move_type == 'in_refund'">Vendor Credit Note</span>
1616
<span t-elif="o.move_type == 'in_invoice'">Vendor Bill</span>
1717
<span t-if="o.name != '/'" t-field="o.name"/>
18-
</h2>
18+
</t>
1919
</xpath>
2020
</template>
2121
<template id="report_invoice" inherit_id="account.report_invoice">

addons/l10n_th/views/report_invoice.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<xpath expr="//div[@name='no_shipping']//span[@t-field='o.partner_id.vat']" position="after">
1212
<span t-esc="o.partner_id.l10n_th_branch_name"/>
1313
</xpath>
14-
<xpath expr="//h2/span[contains(@t-if, 'posted')]" position="replace">
14+
<xpath expr="//t[@t-set='layout_document_title']/span[contains(@t-if, 'posted')]" position="replace">
1515
<t t-if="o.move_type == 'out_invoice' and o.state == 'posted'">
1616
<span t-if="o.company_id.account_fiscal_country_id.code == 'TH' and not commercial_invoice">Tax Invoice</span>
1717
<span t-else="">Invoice</span>

addons/l10n_zm_account/views/report_invoice.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<xpath expr="//div[@id='informations']" position="before">
55
<t t-set="forced_vat" t-value="o.company_id.vat"/>
66
</xpath>
7-
<xpath expr="//div[hasclass('page')]/h2" position="replace">
8-
<h2>
7+
<xpath expr="//div[hasclass('page')]/t[@t-set='layout_document_title']" position="replace">
8+
<t t-set="layout_document_title">
99
<span t-if="o.move_type == 'out_invoice' and o.state == 'posted'">Fiscal Tax Invoice</span>
1010
<span t-elif="o.move_type == 'out_invoice' and o.state == 'draft'">Draft Tax Invoice</span>
1111
<span t-elif="o.move_type == 'out_invoice' and o.state == 'cancel'">Cancelled Tax Invoice</span>
@@ -15,7 +15,7 @@
1515
<span t-elif="o.move_type == 'in_refund'">Vendor Credit Note</span>
1616
<span t-elif="o.move_type == 'in_invoice'">Vendor Bill</span>
1717
<span t-if="o.name != '/'" t-field="o.name"/>
18-
</h2>
18+
</t>
1919
</xpath>
2020
</template>
2121
<template id="report_invoice" inherit_id="account.report_invoice">

addons/purchase/report/purchase_order_templates.xml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@
2121
<div class="oe_structure"/>
2222

2323
<div class="mt-4">
24-
<h2 t-if="o.state in ['draft', 'sent', 'to approve']">Request for Quotation #<span t-field="o.name"/></h2>
25-
<h2 t-if="o.state in ['purchase', 'done']">Purchase Order #<span t-field="o.name"/></h2>
26-
<h2 t-if="o.state == 'cancel'">Cancelled Purchase Order #<span t-field="o.name"/></h2>
24+
<t t-set="layout_document_title">
25+
<t t-if="o.state in ['draft', 'sent', 'to approve']">Request for Quotation #<span t-field="o.name"/></t>
26+
<t t-if="o.state in ['purchase', 'done']">Purchase Order #<span t-field="o.name"/></t>
27+
<t t-if="o.state == 'cancel'">Cancelled Purchase Order #<span t-field="o.name"/></t>
28+
</t>
2729
</div>
2830

2931
<div id="informations" class="row mb-4">

0 commit comments

Comments
 (0)