Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Romain Courteaud
erp5
Commits
a5e3bc8b
Commit
a5e3bc8b
authored
Apr 10, 2014
by
Sebastien Robin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ERP5/PresencePeriod: fixed _getDatePeriodDataList
parent
24c760d3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
15 deletions
+21
-15
product/ERP5/Document/PresencePeriod.py
product/ERP5/Document/PresencePeriod.py
+9
-3
product/ERP5/tests/testCalendar.py
product/ERP5/tests/testCalendar.py
+12
-12
No files found.
product/ERP5/Document/PresencePeriod.py
View file @
a5e3bc8b
...
@@ -29,6 +29,7 @@
...
@@ -29,6 +29,7 @@
#
#
##############################################################################
##############################################################################
from
copy
import
copy
from
AccessControl
import
ClassSecurityInfo
from
AccessControl
import
ClassSecurityInfo
from
Products.ERP5Type
import
Permissions
,
PropertySheet
from
Products.ERP5Type
import
Permissions
,
PropertySheet
...
@@ -84,7 +85,7 @@ class PresencePeriod(Movement, PeriodicityMixin):
...
@@ -84,7 +85,7 @@ class PresencePeriod(Movement, PeriodicityMixin):
calendar_stop_date
=
self
.
getStopDate
()
calendar_stop_date
=
self
.
getStopDate
()
if
(
calendar_start_date
is
not
None
)
and
(
calendar_stop_date
is
not
None
):
if
(
calendar_start_date
is
not
None
)
and
(
calendar_stop_date
is
not
None
):
# Convert Days to second
# Convert Days to second
quantity
=
int
(
calendar_stop_date
)
-
int
(
calendar_start_date
)
quantity
=
abs
(
int
(
calendar_stop_date
)
-
int
(
calendar_start_date
)
)
else
:
else
:
quantity
=
default
quantity
=
default
return
quantity
return
quantity
...
@@ -103,8 +104,13 @@ class PresencePeriod(Movement, PeriodicityMixin):
...
@@ -103,8 +104,13 @@ class PresencePeriod(Movement, PeriodicityMixin):
"""
"""
result
=
[]
result
=
[]
if
self
.
getSource
()
!=
None
or
self
.
getDestination
()
!=
None
:
if
self
.
getSource
()
!=
None
or
self
.
getDestination
()
!=
None
:
for
date_period_data
in
self
.
_getDatePeriodDataList
():
for
period_data
in
self
.
_getDatePeriodDataList
():
result
.
append
(
self
.
asContext
(
self
,
**
date_period_data
))
period_data
=
copy
(
period_data
)
date_list
=
[
period_data
[
'start_date'
],
period_data
[
'stop_date'
]]
date_list
.
sort
()
period_data
[
'start_date'
]
=
date_list
[
0
]
period_data
[
'stop_date'
]
=
date_list
[
1
]
result
.
append
(
self
.
asContext
(
self
,
**
period_data
))
return
result
return
result
def
_getDatePeriodDataList
(
self
):
def
_getDatePeriodDataList
(
self
):
...
...
product/ERP5/tests/testCalendar.py
View file @
a5e3bc8b
...
@@ -162,7 +162,7 @@ class TestCalendar(ERP5ReportTestCase):
...
@@ -162,7 +162,7 @@ class TestCalendar(ERP5ReportTestCase):
destination_value
=
person
,
destination_value
=
person
,
resource_value
=
self
.
portal
.
service_module
.
consulting_service
,
resource_value
=
self
.
portal
.
service_module
.
consulting_service
,
start_date
=
self
.
start_date
,
start_date
=
self
.
start_date
,
stop_date
=
self
.
stop_date
,
stop_date
=
self
.
periodicity_
stop_date
,
specialise_value
=
group_calendar
)
specialise_value
=
group_calendar
)
assignment
.
confirm
()
assignment
.
confirm
()
sequence
.
edit
(
assignment
=
assignment
)
sequence
.
edit
(
assignment
=
assignment
)
...
@@ -464,9 +464,6 @@ class TestCalendar(ERP5ReportTestCase):
...
@@ -464,9 +464,6 @@ class TestCalendar(ERP5ReportTestCase):
date_period_list
=
obj_to_check
.
_getDatePeriodDataList
()
date_period_list
=
obj_to_check
.
_getDatePeriodDataList
()
# Check 1 period
# Check 1 period
self
.
assertEqual
(
second_availability
,
person
.
getAvailableTime
(
from_date
=
start_date
,
to_date
=
stop_date
))
self
.
assertEqual
(
second_availability
,
self
.
assertEqual
(
second_availability
,
person
.
getAvailableTime
(
from_date
=
start_date
,
person
.
getAvailableTime
(
from_date
=
start_date
,
to_date
=
stop_date
))
to_date
=
stop_date
))
...
@@ -556,7 +553,7 @@ class TestCalendar(ERP5ReportTestCase):
...
@@ -556,7 +553,7 @@ class TestCalendar(ERP5ReportTestCase):
start_date
=
self
.
start_date
start_date
=
self
.
start_date
stop_date
=
self
.
stop_date
stop_date
=
self
.
stop_date
second_availability
=
int
(
stop_date
)
-
int
(
start_date
)
second_availability
=
int
(
stop_date
)
-
int
(
start_date
)
date_period_list
=
obj_to_check
.
_getDatePeriodList
()
date_period_list
=
obj_to_check
.
_getDatePeriod
Data
List
()
# Check 1 period
# Check 1 period
self
.
assertEqual
(
0
,
self
.
assertEqual
(
0
,
...
@@ -566,7 +563,7 @@ class TestCalendar(ERP5ReportTestCase):
...
@@ -566,7 +563,7 @@ class TestCalendar(ERP5ReportTestCase):
self
.
assertEqual
(
second_availability
,
self
.
assertEqual
(
second_availability
,
person
.
getAvailableTime
(
person
.
getAvailableTime
(
from_date
=
start_date
,
from_date
=
start_date
,
to_date
=
date_period_list
[
1
][
1
]))
to_date
=
date_period_list
[
1
][
'stop_date'
]))
# # Check all periods
# # Check all periods
# self.assertEqual(len(date_period_list) * second_availability,
# self.assertEqual(len(date_period_list) * second_availability,
# person.getAvailableTime())
# person.getAvailableTime())
...
@@ -1241,13 +1238,16 @@ class TestCalendar(ERP5ReportTestCase):
...
@@ -1241,13 +1238,16 @@ class TestCalendar(ERP5ReportTestCase):
portal_type
=
'Group Presence Period'
)
portal_type
=
'Group Presence Period'
)
group_calendar_period
.
setStartDate
(
'2008/01/01 08:00'
)
group_calendar_period
.
setStartDate
(
'2008/01/01 08:00'
)
group_calendar_period
.
setStopDate
(
'2008/01/01 18:00'
)
group_calendar_period
.
setStopDate
(
'2008/01/01 18:00'
)
group_calendar_period
.
setResourceValue
(
self
.
portal
.
portal_categories
.
calendar_period_type
.
type1
)
group_calendar
.
confirm
()
group_calendar
.
confirm
()
person
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
)
person
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
)
assignment
=
person
.
newContent
(
portal_type
=
'Assignment'
,
assignment
=
self
.
portal
.
group_calendar_assignment_module
.
newContent
(
calendar_value
=
group_calendar
)
specialise_value
=
group_calendar
,
resource_value
=
self
.
portal
.
service_module
.
consulting_service
,
start_date
=
DateTime
(
2008
,
1
,
1
).
earliestTime
(),
stop_date
=
DateTime
(
2008
,
1
,
1
).
latestTime
(),
destination_value
=
person
)
assignment
.
confirm
()
self
.
tic
()
self
.
tic
()
leave_request
=
self
.
portal
.
leave_request_module
.
newContent
(
leave_request
=
self
.
portal
.
leave_request_module
.
newContent
(
portal_type
=
'Leave Request'
)
portal_type
=
'Leave Request'
)
...
@@ -1256,13 +1256,13 @@ class TestCalendar(ERP5ReportTestCase):
...
@@ -1256,13 +1256,13 @@ class TestCalendar(ERP5ReportTestCase):
leave_request_period_1
.
setStartDate
(
'2008/01/01 09:00'
)
leave_request_period_1
.
setStartDate
(
'2008/01/01 09:00'
)
leave_request_period_1
.
setStopDate
(
'2008/01/01 10:00'
)
leave_request_period_1
.
setStopDate
(
'2008/01/01 10:00'
)
leave_request_period_1
.
setResourceValue
(
leave_request_period_1
.
setResourceValue
(
self
.
portal
.
portal_categories
.
calendar_period_type
.
type1
)
self
.
portal
.
service_module
.
consulting_service
)
leave_request_period_2
=
leave_request
.
newContent
(
leave_request_period_2
=
leave_request
.
newContent
(
portal_type
=
'Leave Request Period'
)
portal_type
=
'Leave Request Period'
)
leave_request_period_2
.
setStartDate
(
'2008/01/01 10:00'
)
leave_request_period_2
.
setStartDate
(
'2008/01/01 10:00'
)
leave_request_period_2
.
setStopDate
(
'2008/01/01 11:00'
)
leave_request_period_2
.
setStopDate
(
'2008/01/01 11:00'
)
leave_request_period_2
.
setResourceValue
(
leave_request_period_2
.
setResourceValue
(
self
.
portal
.
portal_categories
.
calendar_period_type
.
type1
)
self
.
portal
.
service_module
.
consulting_service
)
leave_request
.
setDestinationValue
(
person
)
leave_request
.
setDestinationValue
(
person
)
leave_request
.
confirm
()
leave_request
.
confirm
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment