Skip to content

Commit 9e6f1a1

Browse files
[MIG] sale_packaging_report: Migration to 17.0
1 parent dfa60b3 commit 9e6f1a1

File tree

6 files changed

+110
-1
lines changed

6 files changed

+110
-1
lines changed

sale_packaging_report/README.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ Contributors
9696
------------
9797

9898
- Jairo Llopis (`Moduon <https://www.moduon.team/>`__)
99+
- `Heliconia Solutions Pvt. Ltd. <https://www.heliconia.io>`__
99100

100101
Maintainers
101102
-----------

sale_packaging_report/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{
55
"name": "Sale Packaging Report",
66
"summary": "Packaging data in sale reports",
7-
"version": "16.0.1.1.0",
7+
"version": "17.0.1.0.0",
88
"development_status": "Alpha",
99
"category": "Sales",
1010
"website": "https://github.com/OCA/sale-reporting",
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
- Jairo Llopis ([Moduon](https://www.moduon.team/))
2+
- [Heliconia Solutions Pvt. Ltd.](https://www.heliconia.io)

sale_packaging_report/static/description/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,7 @@ <h2><a class="toc-backref" href="#toc-entry-5">Authors</a></h2>
446446
<h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
447447
<ul class="simple">
448448
<li>Jairo Llopis (<a class="reference external" href="https://www.moduon.team/">Moduon</a>)</li>
449+
<li><a class="reference external" href="https://www.heliconia.io">Heliconia Solutions Pvt. Ltd.</a></li>
449450
</ul>
450451
</div>
451452
<div class="section" id="maintainers">
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import test_sale_packaging_report
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# Copyright 2023 Moduon Team S.L.
2+
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0)
3+
4+
from odoo.tests import TransactionCase
5+
6+
7+
class TestSaleReportPackaging(TransactionCase):
8+
@classmethod
9+
def setUpClass(cls):
10+
super().setUpClass()
11+
cls.partner = cls.env.ref("base.res_partner_12")
12+
cls.product = cls.env.ref("product.product_product_9")
13+
cls.product_packaging = cls.env["product.packaging"].create(
14+
{
15+
"name": "Box of 12",
16+
"qty": 12,
17+
"product_id": cls.product.id,
18+
}
19+
)
20+
cls.order = cls.env["sale.order"].create(
21+
{
22+
"partner_id": cls.partner.id,
23+
"order_line": [
24+
(
25+
0,
26+
0,
27+
{
28+
"product_id": cls.product.id,
29+
"product_uom": cls.product.uom_id.id,
30+
"product_uom_qty": 24.0,
31+
"product_packaging_id": cls.product_packaging.id,
32+
"product_packaging_qty": 2,
33+
},
34+
)
35+
],
36+
}
37+
)
38+
39+
def test_product_packaging_fields_in_report(self):
40+
self.order.action_confirm()
41+
42+
select_fields = self.env["sale.report"]._select_additional_fields()
43+
group_by_fields = self.env["sale.report"]._group_by_sale()
44+
from_clause = self.env["sale.report"]._from_sale()
45+
46+
self.assertIn(
47+
"product_packaging_id",
48+
select_fields,
49+
"'product_packaging_id' is not in the select fields.",
50+
)
51+
self.assertIn(
52+
"product_packaging_qty",
53+
select_fields,
54+
"'product_packaging_qty' is not in the select fields.",
55+
)
56+
self.assertIn(
57+
"product_packaging_qty_delivered",
58+
select_fields,
59+
"'product_packaging_qty_delivered' is not in the select fields.",
60+
)
61+
62+
self.assertIn(
63+
"l.product_packaging_id",
64+
group_by_fields,
65+
"'product_packaging_id' is not in the GROUP BY clause.",
66+
)
67+
68+
self.assertIn(
69+
"LEFT JOIN product_packaging",
70+
from_clause,
71+
"LEFT JOIN with 'product_packaging' is missing in the FROM clause.",
72+
)
73+
74+
def test_product_packaging_report_values(self):
75+
self.order.action_confirm()
76+
77+
self.env.invalidate_all()
78+
sale_report = self.env["sale.report"].read_group(
79+
domain=[("order_reference", "=", f"sale.order,{self.order.id}")],
80+
fields=[
81+
"product_packaging_id",
82+
"product_packaging_qty",
83+
"product_packaging_qty_delivered",
84+
],
85+
groupby=["product_packaging_id"],
86+
)
87+
88+
self.assertTrue(sale_report, "No sale report entries found for the sale order.")
89+
90+
report_entry = sale_report[0]
91+
self.assertEqual(
92+
report_entry["product_packaging_id"][0],
93+
self.product_packaging.id,
94+
"Incorrect product packaging in the report.",
95+
)
96+
self.assertEqual(
97+
report_entry["product_packaging_qty"],
98+
2,
99+
"Incorrect product packaging quantity in the report.",
100+
)
101+
self.assertEqual(
102+
report_entry["product_packaging_qty_delivered"],
103+
0,
104+
"Incorrect product packaging delivered quantity in the report.",
105+
)

0 commit comments

Comments
 (0)