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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Xiaowu Zhang
erp5
Commits
6c9a4a00
Commit
6c9a4a00
authored
Jan 03, 2022
by
Xiaowu Zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_travel_expense&test: handle quantity
parent
52a2a300
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
110 additions
and
32 deletions
+110
-32
bt5/erp5_travel_expense/SkinTemplateItem/portal_skins/erp5_hr_record/LeaveRequestRecord_updateRelatedTicket.py
.../erp5_hr_record/LeaveRequestRecord_updateRelatedTicket.py
+64
-20
bt5/erp5_travel_expense/SkinTemplateItem/portal_skins/erp5_hr_record/LeaveRequest_createRepresentativeRecord.py
...erp5_hr_record/LeaveRequest_createRepresentativeRecord.py
+5
-12
bt5/erp5_travel_expense_ui_test/TestTemplateItem/portal_components/test.erp5.testOfficeJSTravelExpense.py
.../portal_components/test.erp5.testOfficeJSTravelExpense.py
+41
-0
No files found.
bt5/erp5_travel_expense/SkinTemplateItem/portal_skins/erp5_hr_record/LeaveRequestRecord_updateRelatedTicket.py
View file @
6c9a4a00
portal
=
context
.
getPortalObject
()
record
=
context
def
getNextMonth
(
year
,
month
):
if
month
==
12
:
return
year
+
1
,
1
else
:
return
year
,
month
+
1
def
getLastDayOfMonth
(
year
,
month
):
next_month_year
,
next_month_month
=
getNextMonth
(
year
,
month
)
datetime
=
DateTime
(
next_month_year
,
next_month_month
,
1
)
-
1
return
datetime
.
day
()
def
getEndOfMonth
(
date
):
year
=
date
.
year
()
month
=
date
.
month
()
day
=
getLastDayOfMonth
(
year
,
month
)
return
DateTime
(
year
,
month
,
day
)
if
record
.
getDestinationReference
()
is
not
None
:
ticket_brain_list
=
portal
.
portal_catalog
(
portal_type
=
"Leave Request"
,
...
...
@@ -23,33 +42,58 @@ record.setDestinationReference(ticket.getReference())
record
.
setFollowUpValue
(
ticket
)
stop_date
=
DateTime
(
record
.
getStopDate
()).
latestTime
()
start_date
=
DateTime
(
record
.
getStartDate
())
ticket
.
edit
(
title
=
"Cong
\
xc3
\
xa9
"
+
record
.
getSourceTitle
(),
# XXX resource=record.getResource(),
#start_date=DateTime(record.getStartDate()),
#stop_date=DateTime(record.getStopDate()),
#animation_center=record.getSite(),
#travel_destination=record.getDestinationNodeTitle(),
# XX Hackish
description
=
record
.
getComment
(),
title
=
"Cong
\
xc3
\
xa9
"
+
record
.
getSourceTitle
(),
start_date
=
start_date
,
stop_date
=
stop_date
,
effective_date
=
start_date
,
description
=
record
.
getComment
(),
resource
=
record
.
getResource
()
)
line_list
=
ticket
.
objectValues
(
portal_type
=
"Leave Request Period"
)
if
len
(
line_list
)
==
0
:
line
=
ticket
.
newContent
(
portal_type
=
"Leave Request Period"
)
elif
len
(
line_list
)
==
1
:
line
=
line_list
[
0
]
else
:
raise
ValueError
(
"incorrect number of Leave Request Period in %s"
%
ticket
.
getRelativeUrl
())
line
.
edit
(
start_date
=
DateTime
(
record
.
getStartDate
()),
stop_date
=
DateTime
(
record
.
getStopDate
()).
latestTime
(),
resource
=
record
.
getResource
(),
months
=
(
stop_date
.
year
()
-
start_date
.
year
())
*
12
+
(
stop_date
.
month
()
-
start_date
.
month
())
+
1
if
not
line_list
:
line_list
=
[]
for
_
in
range
(
months
):
line_list
.
append
(
ticket
.
newContent
(
portal_type
=
"Leave Request Period"
))
total_quantity
=
record
.
getQuantity
()
for
line
in
line_list
:
next_last_date
=
getEndOfMonth
(
start_date
)
if
next_last_date
>
stop_date
:
next_last_date
=
stop_date
quantity
=
round
(
next_last_date
.
latestTime
()
-
start_date
)
if
quantity
>
total_quantity
:
quantity
=
total_quantity
line
.
edit
(
start_date
=
start_date
,
stop_date
=
next_last_date
.
latestTime
(),
resource
=
record
.
getResource
(),
quantity
=
quantity
)
total_quantity
-=
quantity
if
total_quantity
<
0
:
total_quantity
=
0
start_date
=
next_last_date
+
1
record
.
deliver
()
ticket
.
LeaveRequest_createRepresentativeRecord
(
...
...
bt5/erp5_travel_expense/SkinTemplateItem/portal_skins/erp5_hr_record/LeaveRequest_createRepresentativeRecord.py
View file @
6c9a4a00
...
...
@@ -8,15 +8,8 @@ else:
if
record
is
None
:
return
"No records"
line_list
=
context
.
objectValues
(
portal_type
=
"Leave Request Period"
)
if
len
(
line_list
)
==
1
:
line
=
line_list
[
0
]
else
:
raise
ValueError
(
"incorrect number of Leave Request Period in %s"
%
context
.
getRelativeUrl
())
if
context
.
getModificationDate
()
<=
record
.
getCreationDate
()
\
and
line
.
getModificationDate
()
<=
record
.
getCreationDate
():
# Nothing to do
if
context
.
getModificationDate
()
<=
record
.
getCreationDate
():
return
"Nothing to do"
...
...
@@ -24,11 +17,11 @@ new_record = record.Base_createCloneDocument(batch_mode=True)
new_record
.
edit
(
title
=
context
.
getTitle
(),
destination_reference
=
context
.
getReference
(),
start_date
=
line
.
getStartDate
(),
stop_date
=
line
.
getStopDate
(),
start_date
=
record
.
getStartDate
(),
stop_date
=
record
.
getStopDate
(),
comment
=
context
.
getDescription
(),
resource
=
line
.
getResource
(),
resource_tilte
=
line
.
getResourceTitle
(),
resource
=
context
.
getResource
(),
resource_tilte
=
context
.
getResourceTitle
(),
)
new_record
.
stop
()
new_record
.
Record_archivePreviousVersions
()
...
...
bt5/erp5_travel_expense_ui_test/TestTemplateItem/portal_components/test.erp5.testOfficeJSTravelExpense.py
View file @
6c9a4a00
...
...
@@ -237,6 +237,47 @@ class TestOfficeJSTravelExpense(ERP5TypeTestCase):
simulation_state
=
"delivered"
)))
def
test_create_leave_request_from_record_with_crossover_date
(
self
):
"""
"""
now
=
DateTime
(
'2021/12/27'
)
end_date
=
DateTime
(
'2022/01/06'
)
record
=
self
.
portal
.
record_module
.
newContent
(
portal_type
=
"Leave Request Record"
,
resource
=
'service_module/hr_test_need_to_sync'
,
start_date
=
now
.
Date
(),
stop_date
=
end_date
.
Date
(),
source_reference
=
"%s"
%
now
,
source
=
'person_module/hr_user'
,
title
=
"Test Leave Record %s"
%
now
,
quantity
=
9
)
self
.
tic
()
self
.
portal
.
portal_alarms
.
alarm_process_draft_record_list
.
activeSense
()
self
.
tic
()
self
.
assertTrue
(
record
.
getSimulationState
(),
"delivered"
)
ticket
=
record
.
getFollowUpValue
()
new_record
=
self
.
portal
.
portal_catalog
.
getResultValue
(
portal_type
=
"Leave Request Record"
,
strict_follow_up_uid
=
record
.
getFollowUpUid
(),
simulation_state
=
"stopped"
)
leave_request_period_list
=
ticket
.
objectValues
(
portal_type
=
'Leave Request Period'
,
sort_on
=
((
'id'
,
'ascending'
),))
self
.
assertEqual
(
len
(
leave_request_period_list
),
2
)
self
.
assertEqual
(
leave_request_period_list
[
0
].
getQuantity
(),
5
)
self
.
assertEqual
(
leave_request_period_list
[
0
].
getStartDate
(),
now
)
self
.
assertEqual
(
leave_request_period_list
[
0
].
getStopDate
(),
DateTime
(
'2021/12/31'
).
latestTime
())
self
.
assertEqual
(
leave_request_period_list
[
1
].
getQuantity
(),
4
)
self
.
assertEqual
(
leave_request_period_list
[
1
].
getStartDate
(),
DateTime
(
'2022/01/01'
))
self
.
assertEqual
(
leave_request_period_list
[
1
].
getStopDate
(),
end_date
.
latestTime
())
self
.
assertIsNotNone
(
new_record
)
self
.
assertEqual
(
record
.
getSource
(),
new_record
.
getSource
())
self
.
assertEqual
(
record
.
getResource
(),
new_record
.
getResource
())
self
.
assertEqual
(
record
.
getStartDate
(),
new_record
.
getStartDate
())
self
.
assertEqual
(
record
.
getStopDate
(),
new_record
.
getStopDate
())
self
.
assertEqual
(
record
.
getQuantity
(),
new_record
.
getQuantity
())
def
test_create_travel_request_from_record
(
self
):
"""
"""
...
...
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