Skip to content

Commit 8cbc119

Browse files
[MIG] sale_order_report_hide_tax: Migration to 18.0
1 parent 86be508 commit 8cbc119

File tree

8 files changed

+201
-38
lines changed

8 files changed

+201
-38
lines changed

sale_order_report_hide_tax/README.rst

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
.. image:: https://odoo-community.org/readme-banner-image
2-
:target: https://odoo-community.org/get-involved?utm_source=readme
3-
:alt: Odoo Community Association
4-
51
==================================
62
Sale order line hide tax in report
73
==================================
@@ -17,17 +13,17 @@ Sale order line hide tax in report
1713
.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
1814
:target: https://odoo-community.org/page/development-status
1915
:alt: Alpha
20-
.. |badge2| image:: https://img.shields.io/badge/license-LGPL--3-blue.png
16+
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
2117
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
2218
:alt: License: LGPL-3
2319
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsale--reporting-lightgray.png?logo=github
24-
:target: https://github.com/OCA/sale-reporting/tree/16.0/sale_order_report_hide_tax
20+
:target: https://github.com/OCA/sale-reporting/tree/18.0/sale_order_report_hide_tax
2521
:alt: OCA/sale-reporting
2622
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
27-
:target: https://translation.odoo-community.org/projects/sale-reporting-16-0/sale-reporting-16-0-sale_order_report_hide_tax
23+
:target: https://translation.odoo-community.org/projects/sale-reporting-18-0/sale-reporting-18-0-sale_order_report_hide_tax
2824
:alt: Translate me on Weblate
2925
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
30-
:target: https://runboat.odoo-community.org/builds?repo=OCA/sale-reporting&target_branch=16.0
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/sale-reporting&target_branch=18.0
3127
:alt: Try me on Runboat
3228

3329
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -67,7 +63,7 @@ Bug Tracker
6763
Bugs are tracked on `GitHub Issues <https://github.com/OCA/sale-reporting/issues>`_.
6864
In case of trouble, please check there if your issue has already been reported.
6965
If you spotted it first, help us to smash it by providing a detailed and welcomed
70-
`feedback <https://github.com/OCA/sale-reporting/issues/new?body=module:%20sale_order_report_hide_tax%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
66+
`feedback <https://github.com/OCA/sale-reporting/issues/new?body=module:%20sale_order_report_hide_tax%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
7167

7268
Do not contact contributors directly about support or help with technical issues.
7369

@@ -82,7 +78,8 @@ Authors
8278
Contributors
8379
------------
8480

85-
- David Vidal (``Moduon <https://www.moduon.team/>``\ \_\_)
81+
- David Vidal (`Moduon <https://www.moduon.team/>`__)
82+
- Sabrina Rodriguez (`Moduon <https://www.moduon.team/>`__)
8683

8784
Maintainers
8885
-----------
@@ -108,6 +105,6 @@ Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:
108105

109106
|maintainer-chienandalu| |maintainer-rafaelbn|
110107

111-
This module is part of the `OCA/sale-reporting <https://github.com/OCA/sale-reporting/tree/16.0/sale_order_report_hide_tax>`_ project on GitHub.
108+
This module is part of the `OCA/sale-reporting <https://github.com/OCA/sale-reporting/tree/18.0/sale_order_report_hide_tax>`_ project on GitHub.
112109

113110
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

sale_order_report_hide_tax/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{
44
"name": "Sale order line hide tax in report",
55
"summary": "Hide taxes column when they don't add value",
6-
"version": "16.0.1.0.1",
6+
"version": "18.0.1.0.1",
77
"development_status": "Alpha",
88
"category": "Sales",
99
"website": "https://github.com/OCA/sale-reporting",

sale_order_report_hide_tax/models/sale_order.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ def _compute_show_tax_column_in_report(self):
1414
self.show_tax_column_in_report = True
1515
for order in self.filtered("order_line"):
1616
order_lines = order.order_line.filtered(lambda x: not x.display_type)
17-
# Can be a recordset if several taxes apply
1817
first_line_tax_group = fields.first(order_lines).tax_id.tax_group_id
1918
# Mixed group taxes, let's show them for clarity
20-
order.show_tax_column_in_report = (
21-
first_line_tax_group != order_lines.tax_id.tax_group_id
19+
order.show_tax_column_in_report = any(
20+
first_line_tax_group != line.tax_id.tax_group_id for line in order_lines
2221
)
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
* David Vidal (`Moduon <https://www.moduon.team/>`__)
1+
- David Vidal ([Moduon](https://www.moduon.team/))
2+
- Sabrina Rodriguez ([Moduon](https://www.moduon.team/))

sale_order_report_hide_tax/reports/sale_order_report_template.xml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,21 @@
33
<template
44
id="report_saleorder_document"
55
inherit_id="sale.report_saleorder_document"
6+
priority="999"
67
>
78
<xpath expr="//th[@name='th_taxes']" position="attributes">
8-
<attribute name="t-if">doc.show_tax_column_in_report</attribute>
9+
<attribute
10+
name="t-if"
11+
add="doc.show_tax_column_in_report"
12+
separator="and"
13+
/>
914
</xpath>
1015
<xpath expr="//td[@name='td_taxes']" position="attributes">
11-
<attribute name="t-if">doc.show_tax_column_in_report</attribute>
16+
<attribute
17+
name="t-if"
18+
add="doc.show_tax_column_in_report"
19+
separator="and"
20+
/>
1221
</xpath>
1322
</template>
1423
</odoo>

sale_order_report_hide_tax/static/description/index.html

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
55
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
6-
<title>README.rst</title>
6+
<title>Sale order line hide tax in report</title>
77
<style type="text/css">
88

99
/*
@@ -360,21 +360,16 @@
360360
</style>
361361
</head>
362362
<body>
363-
<div class="document">
363+
<div class="document" id="sale-order-line-hide-tax-in-report">
364+
<h1 class="title">Sale order line hide tax in report</h1>
364365

365-
366-
<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
367-
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
368-
</a>
369-
<div class="section" id="sale-order-line-hide-tax-in-report">
370-
<h1>Sale order line hide tax in report</h1>
371366
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
372367
!! This file is generated by oca-gen-addon-readme !!
373368
!! changes will be overwritten. !!
374369
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
375370
!! source digest: sha256:c3f8c634c1fae23b76f78082b36599f63225f7b3b09f33d3e5fa90f5b185f557
376371
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
377-
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Alpha" src="https://img.shields.io/badge/maturity-Alpha-red.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/license-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/sale-reporting/tree/16.0/sale_order_report_hide_tax"><img alt="OCA/sale-reporting" src="https://img.shields.io/badge/github-OCA%2Fsale--reporting-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/sale-reporting-16-0/sale-reporting-16-0-sale_order_report_hide_tax"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/sale-reporting&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
372+
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Alpha" src="https://img.shields.io/badge/maturity-Alpha-red.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/sale-reporting/tree/18.0/sale_order_report_hide_tax"><img alt="OCA/sale-reporting" src="https://img.shields.io/badge/github-OCA%2Fsale--reporting-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/sale-reporting-18-0/sale-reporting-18-0-sale_order_report_hide_tax"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/sale-reporting&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
378373
<p>Hide taxes column in the quotation document that is sent to the
379374
customer.</p>
380375
<div class="admonition important">
@@ -398,42 +393,43 @@ <h1>Sale order line hide tax in report</h1>
398393
</ul>
399394
</div>
400395
<div class="section" id="use-cases-context">
401-
<h2><a class="toc-backref" href="#toc-entry-1">Use Cases / Context</a></h2>
396+
<h1><a class="toc-backref" href="#toc-entry-1">Use Cases / Context</a></h1>
402397
<p>When the taxes are the same in every sales line, that information might
403398
be redundant with the taxes summary and takes valuable space that other
404399
columns might take.</p>
405400
<p>This might be event more annoying when there’s tax exemptions like in EU
406401
intracomunitary operations.</p>
407402
</div>
408403
<div class="section" id="usage">
409-
<h2><a class="toc-backref" href="#toc-entry-2">Usage</a></h2>
404+
<h1><a class="toc-backref" href="#toc-entry-2">Usage</a></h1>
410405
<p>Whenever the taxes are in the same group for the whole order the column
411406
won’t be displayed.</p>
412407
</div>
413408
<div class="section" id="bug-tracker">
414-
<h2><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h2>
409+
<h1><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h1>
415410
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/sale-reporting/issues">GitHub Issues</a>.
416411
In case of trouble, please check there if your issue has already been reported.
417412
If you spotted it first, help us to smash it by providing a detailed and welcomed
418-
<a class="reference external" href="https://github.com/OCA/sale-reporting/issues/new?body=module:%20sale_order_report_hide_tax%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
413+
<a class="reference external" href="https://github.com/OCA/sale-reporting/issues/new?body=module:%20sale_order_report_hide_tax%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
419414
<p>Do not contact contributors directly about support or help with technical issues.</p>
420415
</div>
421416
<div class="section" id="credits">
422-
<h2><a class="toc-backref" href="#toc-entry-4">Credits</a></h2>
417+
<h1><a class="toc-backref" href="#toc-entry-4">Credits</a></h1>
423418
<div class="section" id="authors">
424-
<h3><a class="toc-backref" href="#toc-entry-5">Authors</a></h3>
419+
<h2><a class="toc-backref" href="#toc-entry-5">Authors</a></h2>
425420
<ul class="simple">
426421
<li>Moduon</li>
427422
</ul>
428423
</div>
429424
<div class="section" id="contributors">
430-
<h3><a class="toc-backref" href="#toc-entry-6">Contributors</a></h3>
425+
<h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
431426
<ul class="simple">
432-
<li>David Vidal (<tt class="docutils literal">Moduon <span class="pre">&lt;https://www.moduon.team/&gt;</span></tt>__)</li>
427+
<li>David Vidal (<a class="reference external" href="https://www.moduon.team/">Moduon</a>)</li>
428+
<li>Sabrina Rodriguez (<a class="reference external" href="https://www.moduon.team/">Moduon</a>)</li>
433429
</ul>
434430
</div>
435431
<div class="section" id="maintainers">
436-
<h3><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h3>
432+
<h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
437433
<p>This module is maintained by the OCA.</p>
438434
<a class="reference external image-reference" href="https://odoo-community.org">
439435
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
@@ -443,11 +439,10 @@ <h3><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h3>
443439
promote its widespread use.</p>
444440
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainers</a>:</p>
445441
<p><a class="reference external image-reference" href="https://github.com/chienandalu"><img alt="chienandalu" src="https://github.com/chienandalu.png?size=40px" /></a> <a class="reference external image-reference" href="https://github.com/rafaelbn"><img alt="rafaelbn" src="https://github.com/rafaelbn.png?size=40px" /></a></p>
446-
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/sale-reporting/tree/16.0/sale_order_report_hide_tax">OCA/sale-reporting</a> project on GitHub.</p>
442+
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/sale-reporting/tree/18.0/sale_order_report_hide_tax">OCA/sale-reporting</a> project on GitHub.</p>
447443
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
448444
</div>
449445
</div>
450446
</div>
451-
</div>
452447
</body>
453448
</html>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import test_show_tax_column
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
# Copyright 2025 Moduon Team S.L.
2+
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0)
3+
from odoo import Command
4+
5+
from odoo.addons.base.tests.common import BaseCommon
6+
7+
8+
class TestShowTaxColumnInReport(BaseCommon):
9+
@classmethod
10+
def setUpClass(cls):
11+
super().setUpClass()
12+
cls.partner = cls.env["res.partner"].create(
13+
{
14+
"name": "Test Partner",
15+
}
16+
)
17+
cls.product = cls.env["product.product"].create(
18+
{
19+
"name": "Test Product",
20+
}
21+
)
22+
cls.tax_group_1 = cls.env["account.tax.group"].create(
23+
{
24+
"name": "VAT Group 1",
25+
}
26+
)
27+
cls.tax_group_2 = cls.env["account.tax.group"].create(
28+
{
29+
"name": "VAT Group 2",
30+
}
31+
)
32+
cls.tax_group_3 = cls.env["account.tax.group"].create(
33+
{
34+
"name": "VAT Group 3",
35+
}
36+
)
37+
cls.tax_1 = cls.env["account.tax"].create(
38+
{
39+
"name": "Tax 1",
40+
"amount": 10,
41+
"amount_type": "percent",
42+
"tax_group_id": cls.tax_group_1.id,
43+
}
44+
)
45+
cls.tax_2 = cls.env["account.tax"].create(
46+
{
47+
"name": "Tax 2",
48+
"amount": 5,
49+
"amount_type": "percent",
50+
"tax_group_id": cls.tax_group_2.id,
51+
}
52+
)
53+
cls.tax_3 = cls.env["account.tax"].create(
54+
{
55+
"name": "Tax 3",
56+
"amount": 5,
57+
"amount_type": "percent",
58+
"tax_group_id": cls.tax_group_2.id,
59+
}
60+
)
61+
cls.order = cls.env["sale.order"].create(
62+
{
63+
"partner_id": cls.partner.id,
64+
}
65+
)
66+
cls.report = cls.env["ir.actions.report"]._get_report_from_name(
67+
"sale.report_saleorder"
68+
)
69+
70+
def test_same_tax_group_hides_tax_column(self):
71+
self.order.order_line = [
72+
Command.clear(),
73+
Command.create(
74+
{
75+
"product_id": self.product.id,
76+
"name": "Line 1",
77+
"product_uom_qty": 1,
78+
"price_unit": 100,
79+
"tax_id": [(6, 0, [self.tax_1.id])],
80+
}
81+
),
82+
Command.create(
83+
{
84+
"product_id": self.product.id,
85+
"name": "Line 2",
86+
"product_uom_qty": 1,
87+
"price_unit": 50,
88+
"tax_id": [(6, 0, [self.tax_1.id])],
89+
}
90+
),
91+
]
92+
result = self.report._render_qweb_html("sale.report_saleorder", [self.order.id])
93+
html = result[0].decode("utf-8")
94+
self.assertNotIn(
95+
"Taxes",
96+
html,
97+
"""Tax column should be hidden when all taxes
98+
belong to the same tax group""",
99+
)
100+
101+
def test_mixed_tax_groups_show_tax_column(self):
102+
self.order.order_line = [
103+
Command.clear(),
104+
Command.create(
105+
{
106+
"product_id": self.product.id,
107+
"name": "Line 1",
108+
"product_uom_qty": 1,
109+
"price_unit": 100,
110+
"tax_id": [(6, 0, [self.tax_1.id])],
111+
}
112+
),
113+
Command.create(
114+
{
115+
"product_id": self.product.id,
116+
"name": "Line 2",
117+
"product_uom_qty": 1,
118+
"price_unit": 50,
119+
"tax_id": [(6, 0, [self.tax_2.id])],
120+
}
121+
),
122+
]
123+
result = self.report._render_qweb_html("sale.report_saleorder", [self.order.id])
124+
html = result[0].decode("utf-8")
125+
self.assertIn(
126+
"Taxes",
127+
html,
128+
"""The tax column should be displayed when taxes
129+
belong to different tax groups""",
130+
)
131+
132+
def test_mixed_tax_groups_single_line_sow_tax_column(self):
133+
self.order.order_line = [
134+
Command.clear(),
135+
Command.create(
136+
{
137+
"product_id": self.product.id,
138+
"name": "Line 1",
139+
"product_uom_qty": 1,
140+
"price_unit": 100,
141+
"tax_id": [(6, 0, [self.tax_1.id, self.tax_2.id])],
142+
}
143+
),
144+
Command.create(
145+
{
146+
"product_id": self.product.id,
147+
"name": "Line 1",
148+
"product_uom_qty": 1,
149+
"price_unit": 100,
150+
"tax_id": [(6, 0, [self.tax_3.id])],
151+
}
152+
),
153+
]
154+
result = self.report._render_qweb_html("sale.report_saleorder", [self.order.id])
155+
html = result[0].decode("utf-8")
156+
self.assertIn(
157+
"Taxes",
158+
html,
159+
"""The tax column should be displayed when taxes
160+
belong to different tax groups""",
161+
)

0 commit comments

Comments
 (0)