Skip to content

Commit

Permalink
[MIG] sale_packaging_report: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
HeliconiaSolutions committed Jan 17, 2025
1 parent 4b6e518 commit c77f55a
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 1 deletion.
1 change: 1 addition & 0 deletions sale_packaging_report/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ Contributors
------------

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

Maintainers
-----------
Expand Down
2 changes: 1 addition & 1 deletion sale_packaging_report/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"name": "Sale Packaging Report",
"summary": "Packaging data in sale reports",
"version": "16.0.1.1.0",
"version": "17.0.1.0.0",
"development_status": "Alpha",
"category": "Sales",
"website": "https://github.com/OCA/sale-reporting",
Expand Down
1 change: 1 addition & 0 deletions sale_packaging_report/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
- Jairo Llopis ([Moduon](https://www.moduon.team/))
- [Heliconia Solutions Pvt. Ltd.](https://www.heliconia.io)
1 change: 1 addition & 0 deletions sale_packaging_report/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ <h2><a class="toc-backref" href="#toc-entry-5">Authors</a></h2>
<h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
<ul class="simple">
<li>Jairo Llopis (<a class="reference external" href="https://www.moduon.team/">Moduon</a>)</li>
<li><a class="reference external" href="https://www.heliconia.io">Heliconia Solutions Pvt. Ltd.</a></li>
</ul>
</div>
<div class="section" id="maintainers">
Expand Down
1 change: 1 addition & 0 deletions sale_packaging_report/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import test_sale_packaging_report
105 changes: 105 additions & 0 deletions sale_packaging_report/tests/test_sale_packaging_report.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Copyright 2023 Moduon Team S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0)

from odoo.tests import TransactionCase


class TestSaleReportPackaging(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.partner = cls.env.ref("base.res_partner_12")
cls.product = cls.env.ref("product.product_product_9")
cls.product_packaging = cls.env["product.packaging"].create(
{
"name": "Box of 12",
"qty": 12,
"product_id": cls.product.id,
}
)
cls.order = cls.env["sale.order"].create(
{
"partner_id": cls.partner.id,
"order_line": [
(
0,
0,
{
"product_id": cls.product.id,
"product_uom": cls.product.uom_id.id,
"product_uom_qty": 24.0,
"product_packaging_id": cls.product_packaging.id,
"product_packaging_qty": 2,
},
)
],
}
)

def test_product_packaging_fields_in_report(self):
self.order.action_confirm()

select_fields = self.env["sale.report"]._select_additional_fields()
group_by_fields = self.env["sale.report"]._group_by_sale()
from_clause = self.env["sale.report"]._from_sale()

self.assertIn(
"product_packaging_id",
select_fields,
"'product_packaging_id' is not in the select fields.",
)
self.assertIn(
"product_packaging_qty",
select_fields,
"'product_packaging_qty' is not in the select fields.",
)
self.assertIn(
"product_packaging_qty_delivered",
select_fields,
"'product_packaging_qty_delivered' is not in the select fields.",
)

self.assertIn(
"l.product_packaging_id",
group_by_fields,
"'product_packaging_id' is not in the GROUP BY clause.",
)

self.assertIn(
"LEFT JOIN product_packaging",
from_clause,
"LEFT JOIN with 'product_packaging' is missing in the FROM clause.",
)

def test_product_packaging_report_values(self):
self.order.action_confirm()

self.env.invalidate_all()
sale_report = self.env["sale.report"].read_group(
domain=[("order_reference", "=", f"sale.order,{self.order.id}")],
fields=[
"product_packaging_id",
"product_packaging_qty",
"product_packaging_qty_delivered",
],
groupby=["product_packaging_id"],
)

self.assertTrue(sale_report, "No sale report entries found for the sale order.")

report_entry = sale_report[0]
self.assertEqual(
report_entry["product_packaging_id"][0],
self.product_packaging.id,
"Incorrect product packaging in the report.",
)
self.assertEqual(
report_entry["product_packaging_qty"],
2,
"Incorrect product packaging quantity in the report.",
)
self.assertEqual(
report_entry["product_packaging_qty_delivered"],
0,
"Incorrect product packaging delivered quantity in the report.",
)

0 comments on commit c77f55a

Please sign in to comment.