23
23
next_yearly = today() + RelativeDate(years=+2,day=3, month=3)
24
24
assert next_date == next_yearly, "Next date is not March, the 3rd of year+2"
26
Change the start date to today
26
Change the start date to October the 3rd.
28
28
!record {model: stock.frequence, id: yearly1}:
29
29
start_date: 2009-01-01
30
last_run: !eval time.strftime('%Y-%m-%d')
30
last_run: !eval time.strftime('2009-%m-%d')
31
31
yearly_day: !eval time.localtime()[2]
32
32
yearly_choose_month: !eval time.localtime()[1]
49
50
!python {model: stock.frequence}: |
50
51
from mx.DateTime import *
51
52
next_date = Parser.DateFromString(self.browse(cr, uid, ref('yearly1')).next_date)
52
assert next_date == DateTime(today().year+2, 10, 3) and next_date >= today(), "Next date is not October, the 3rd of %s"%(today().year+2,)
53
next_yearly = DateTime(2009, 10, 03)
54
if (today().year-2009)%2 == 0:
55
if today().month < 10 or (today().month == 10 and today().day < 3):
56
assert next_date == DateTime(today().year, 10, 3) and next_date >= today(), "Next date is not October, the 3rd of the current year"
58
assert next_date == DateTime(today().year+2, 10, 3) and next_date >= today(), "Next date is not October, the 3rd of %s"%(today().year+2,)
60
assert next_date == DateTime(today().year+1, 10, 3) and next_date >= today(), "Next date is not October, the 3rd of %s"%(today().year+1,)
79
87
assert next == next_date, "The next date is not the first Wednesday of March (1)"
81
89
assert today() == next_date, "The next date is not the first Wednesday of March (2)"
85
!record {model: stock.frequence, id: yearly3}:
90
yearly_choose_month: 3
91
start_date: !eval time.strftime('%Y-03-03')
92
last_run: !eval time.strftime('%Y-03-03')
95
Check if the next date is the next March, the 3rd of an odd-numbered year
97
!python {model: stock.frequence}: |
98
from mx.DateTime import *
99
next_date = Parser.DateFromString(self.browse(cr, uid, ref('yearly3')).next_date)
100
next_yearly = today() + RelativeDate(years=+2,day=3, month=3)
101
assert next_date == next_yearly, "Next date is not March, the 3rd of year+2"
103
Change the start date to October the 3rd.
105
!record {model: stock.frequence, id: yearly3}:
106
start_date: 2009-01-01
107
last_run: !eval time.strftime('2009-%m-%d')
108
yearly_day: !eval time.localtime()[2]
109
yearly_choose_month: !eval time.localtime()[1]
111
Check if the next date is always March, the 3rd of an odd-numbered year
113
!python {model: stock.frequence}: |
114
from mx.DateTime import *
115
next_date = Parser.DateFromString(self.browse(cr, uid, ref('yearly3')).next_date)
116
last_run = Parser.DateFromString(self.browse(cr, uid, ref('yearly3')).last_run)
117
if (now() - last_run).days > 730:
118
assert (next_date.year-today().year) == 0, 'Next date is not today'
120
assert (next_date.year-2009)%2 == 0, 'Next date is not multiple of 2'
121
assert next_date.month == today().month and next_date.day == today().day, 'Next date is not March, the 3rd (2)'
123
Change the choose month to October
125
!record {model: stock.frequence, id: yearly3}:
126
yearly_choose_month: 10
129
Check if the next date is now the next October, the 3rd
131
!python {model: stock.frequence}: |
132
from mx.DateTime import *
133
next_date = Parser.DateFromString(self.browse(cr, uid, ref('yearly3')).next_date)
134
last_run = Parser.DateFromString(self.browse(cr, uid, ref('yearly3')).last_run)
135
next_yearly = DateTime(2009, 10, 03)
136
if (now() - last_run).days > 730:
137
assert next_date == DateTime(now().year, now().month, now().day), "Next date is not today"
139
if (today().year-2009)%2 == 0:
140
if today().month < 10 or (today().month == 10 and today().day <= 3):
141
assert next_date == DateTime(today().year, 10, 3) and next_date >= today(), "Next date is not October, the 3rd of the current year"
143
assert next_date == DateTime(today().year+2, 10, 3) and next_date >= today(), "Next date is not October, the 3rd of %s"%(today().year+2,)
145
assert next_date == DateTime(today().year+1, 10, 3) and next_date >= today(), "Next date is not October, the 3rd of %s"%(today().year+1,)
b'\\ No newline at end of file'