1
1
# Copyright 2024 Camptocamp (<https://www.camptocamp.com>).
2
2
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
3
+ from datetime import date
4
+
3
5
from odoo import Command
4
6
from odoo .exceptions import ValidationError
5
7
from odoo .tests import TransactionCase , tagged
@@ -10,6 +12,8 @@ class TestVendorPromotion(TransactionCase):
10
12
@classmethod
11
13
def setUpClass (cls ):
12
14
super ().setUpClass ()
15
+ cls .current_year = date .today ().year
16
+ cls .next_year = date .today ().year + 1
13
17
cls .company_a = cls .env ["res.company" ].create ({"name" : "Company A" })
14
18
cls .warehouse_a = cls .env ["stock.warehouse" ].search (
15
19
[("company_id" , "=" , cls .company_a .id )], limit = 1
@@ -40,8 +44,8 @@ def setUpClass(cls):
40
44
"product_tmpl_id" : cls .product .product_tmpl_id .id ,
41
45
"min_qty" : 1 ,
42
46
"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 ) ,
45
49
},
46
50
{
47
51
"partner_id" : cls .vendor2 .id ,
@@ -50,8 +54,8 @@ def setUpClass(cls):
50
54
"min_qty" : 1 ,
51
55
"price" : 120 ,
52
56
"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 ) ,
55
59
},
56
60
]
57
61
)
@@ -65,7 +69,7 @@ def test_promotion_dates_validation(self):
65
69
"min_qty" : 1 ,
66
70
"price" : 100 ,
67
71
"is_promotion" : True ,
68
- "date_start" : "2025-01-01" ,
72
+ "date_start" : date ( self . next_year , 1 , 1 ) ,
69
73
}
70
74
)
71
75
@@ -74,7 +78,7 @@ def test_purchase_vendor_promotion(self):
74
78
purchase_order = self .env ["purchase.order" ].create (
75
79
{
76
80
"partner_id" : self .vendor2 .id ,
77
- "date_planned" : "2024-06-01" ,
81
+ "date_planned" : date ( self . current_year , 6 , 1 ) ,
78
82
"company_id" : self .company_a .id ,
79
83
"order_line" : [
80
84
Command .create (
@@ -102,4 +106,9 @@ def test_orderpoint_promotion(self):
102
106
}
103
107
)
104
108
)
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