Skip to content

Commit

Permalink
Merge PR #2509 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by HviorForgeFlow
  • Loading branch information
OCA-git-bot committed Jan 10, 2025
2 parents e3f1805 + c42142c commit bbc0a19
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions purchase_vendor_promotion/tests/test_vendor_promotion.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Copyright 2024 Camptocamp (<https://www.camptocamp.com>).
# 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
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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),
},
]
)
Expand All @@ -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),
}
)

Expand All @@ -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(
Expand Down Expand Up @@ -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')}",
)

0 comments on commit bbc0a19

Please sign in to comment.