diff --git a/purchase_vendor_promotion/tests/test_vendor_promotion.py b/purchase_vendor_promotion/tests/test_vendor_promotion.py index 5a8adfa679c..17bc3444050 100644 --- a/purchase_vendor_promotion/tests/test_vendor_promotion.py +++ b/purchase_vendor_promotion/tests/test_vendor_promotion.py @@ -1,5 +1,7 @@ # Copyright 2024 Camptocamp (). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from datetime import date + from odoo import Command from odoo.exceptions import ValidationError from odoo.tests import TransactionCase, tagged @@ -10,6 +12,8 @@ class TestVendorPromotion(TransactionCase): @classmethod def setUpClass(cls): super().setUpClass() + cls.current_year = date.today().year + cls.next_year = date.today().year + 1 cls.company_a = cls.env["res.company"].create({"name": "Company A"}) cls.warehouse_a = cls.env["stock.warehouse"].search( [("company_id", "=", cls.company_a.id)], limit=1 @@ -40,8 +44,8 @@ def setUpClass(cls): "product_tmpl_id": cls.product.product_tmpl_id.id, "min_qty": 1, "price": 100, - "date_start": "2025-01-01", - "date_end": "2025-12-31", + "date_start": date(cls.next_year, 1, 1), + "date_end": date(cls.next_year, 12, 31), }, { "partner_id": cls.vendor2.id, @@ -50,8 +54,8 @@ def setUpClass(cls): "min_qty": 1, "price": 120, "is_promotion": True, - "date_start": "2024-01-01", - "date_end": "2024-12-31", + "date_start": date(cls.current_year, 1, 1), + "date_end": date(cls.current_year, 12, 31), }, ] ) @@ -65,7 +69,7 @@ def test_promotion_dates_validation(self): "min_qty": 1, "price": 100, "is_promotion": True, - "date_start": "2025-01-01", + "date_start": date(self.next_year, 1, 1), } ) @@ -74,7 +78,7 @@ def test_purchase_vendor_promotion(self): purchase_order = self.env["purchase.order"].create( { "partner_id": self.vendor2.id, - "date_planned": "2024-06-01", + "date_planned": date(self.current_year, 6, 1), "company_id": self.company_a.id, "order_line": [ Command.create( @@ -102,4 +106,9 @@ def test_orderpoint_promotion(self): } ) ) - self.assertEqual(orderpoint.promotion_period, "2024-01-01 - 2024-12-31") + self.assertEqual( + orderpoint.promotion_period, + f"{date(self.current_year, 1, 1).strftime('%Y-%m-%d')}" + " - " + f"{date(self.current_year, 12, 31).strftime('%Y-%m-%d')}", + )