Skip to content

Commit bbc0a19

Browse files
committed
Merge PR #2509 into 16.0
Signed-off-by HviorForgeFlow
2 parents e3f1805 + c42142c commit bbc0a19

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

purchase_vendor_promotion/tests/test_vendor_promotion.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Copyright 2024 Camptocamp (<https://www.camptocamp.com>).
22
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
3+
from datetime import date
4+
35
from odoo import Command
46
from odoo.exceptions import ValidationError
57
from odoo.tests import TransactionCase, tagged
@@ -10,6 +12,8 @@ class TestVendorPromotion(TransactionCase):
1012
@classmethod
1113
def setUpClass(cls):
1214
super().setUpClass()
15+
cls.current_year = date.today().year
16+
cls.next_year = date.today().year + 1
1317
cls.company_a = cls.env["res.company"].create({"name": "Company A"})
1418
cls.warehouse_a = cls.env["stock.warehouse"].search(
1519
[("company_id", "=", cls.company_a.id)], limit=1
@@ -40,8 +44,8 @@ def setUpClass(cls):
4044
"product_tmpl_id": cls.product.product_tmpl_id.id,
4145
"min_qty": 1,
4246
"price": 100,
43-
"date_start": "2025-01-01",
44-
"date_end": "2025-12-31",
47+
"date_start": date(cls.next_year, 1, 1),
48+
"date_end": date(cls.next_year, 12, 31),
4549
},
4650
{
4751
"partner_id": cls.vendor2.id,
@@ -50,8 +54,8 @@ def setUpClass(cls):
5054
"min_qty": 1,
5155
"price": 120,
5256
"is_promotion": True,
53-
"date_start": "2024-01-01",
54-
"date_end": "2024-12-31",
57+
"date_start": date(cls.current_year, 1, 1),
58+
"date_end": date(cls.current_year, 12, 31),
5559
},
5660
]
5761
)
@@ -65,7 +69,7 @@ def test_promotion_dates_validation(self):
6569
"min_qty": 1,
6670
"price": 100,
6771
"is_promotion": True,
68-
"date_start": "2025-01-01",
72+
"date_start": date(self.next_year, 1, 1),
6973
}
7074
)
7175

@@ -74,7 +78,7 @@ def test_purchase_vendor_promotion(self):
7478
purchase_order = self.env["purchase.order"].create(
7579
{
7680
"partner_id": self.vendor2.id,
77-
"date_planned": "2024-06-01",
81+
"date_planned": date(self.current_year, 6, 1),
7882
"company_id": self.company_a.id,
7983
"order_line": [
8084
Command.create(
@@ -102,4 +106,9 @@ def test_orderpoint_promotion(self):
102106
}
103107
)
104108
)
105-
self.assertEqual(orderpoint.promotion_period, "2024-01-01 - 2024-12-31")
109+
self.assertEqual(
110+
orderpoint.promotion_period,
111+
f"{date(self.current_year, 1, 1).strftime('%Y-%m-%d')}"
112+
" - "
113+
f"{date(self.current_year, 12, 31).strftime('%Y-%m-%d')}",
114+
)

0 commit comments

Comments
 (0)