Commit cbf200d7 authored by Rafael Monnerat's avatar Rafael Monnerat

Handle Leave request w/o hr special app

See merge request !1963
parents 37d0a9bd c0e566bd
Pipeline #36196 failed with stage
in 0 seconds
portal = context.getPortalObject()
maileva_connector = context.MailevaSOAPConnector_getAvailableConnector()
maileva_connector = portal.ERP5Site_getAvailableMailevaSOAPConnector()
notification_dict = maileva_connector.checkPendingNotifications()
......
......@@ -54,7 +54,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>MailevaSOAPConnector_getAvailableConnector</string> </value>
<value> <string>ERP5Site_getAvailableMailevaSOAPConnector</string> </value>
</item>
</dictionary>
</pickle>
......
maileva_connector = context.MailevaSOAPConnector_getAvailableConnector()
maileva_connector = context.getPortalObject().ERP5Site_getAvailableMailevaSOAPConnector()
result = maileva_connector.getPendingNotificationDetails(track_id)
if result['status'] == "SENT":
document = context.getFollowUpValue()
......
......@@ -4,7 +4,7 @@ now = DateTime()
portal = context.getPortalObject()
# Do some check here
maileva_connector = context.MailevaSOAPConnector_getAvailableConnector()
maileva_connector = portal.ERP5Site_getAvailableMailevaSOAPConnector()
today = now.toZone('UTC').asdatetime().strftime('%Y-%m-%d')
number = str(portal.portal_ids.generateNewId(
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_jio_action</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_jio_action</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>add_leave_request</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>View</string>
</tuple>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Action Information</string> </value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>20.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Add Leave Request</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/PaySheetTransaction_viewAddLeaveRequestDialog</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>python:portal.Base_checkPermission(\'leave_request_module\', \'Add portal content\')</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_jio_jump</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_jio_jump</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>jump_to_holiday_acquisition</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>View</string>
</tuple>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Action Information</string> </value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>20.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Holiday Acquisitions</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/PaySheetTransaction_jumpToHolidayAcquisition</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>python:portal.Base_checkPermission(\'holiday_acquisition_module\', \'Add portal content\')</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_jio_jump</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_jio_jump</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>jump_to_leave_request</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>View</string>
</tuple>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Action Information</string> </value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>21.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Leave Requests</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/PaySheetTransaction_jumpToLeaveRequest</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>python:portal.Base_checkPermission(\'leave_request_module\', \'Add portal content\')</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
holiday_acquisition = context.getCausalityRelatedValue(portal_type='Holiday Acquisition')
if holiday_acquisition:
return holiday_acquisition.Base_redirect('view', keep_items={'portal_status_message': context.Base_translateString('Holiday Acquisition is already created')})
return holiday_acquisition.Base_redirect('view',
keep_items={
'portal_status_message':
context.Base_translateString('Holiday Acquisition is already created')})
employee = context.getSourceSectionValue()
stop_date = context.getStopDate()
......@@ -10,7 +13,10 @@ work_hour = context.getWorkTimeAnnotationLineQuantity(0)
if work_hour is None:
return context.Base_redirect('view',
context.Base_translateString('Cannot create a Holiday Acquisition without set work time.'))
keep_items={
'portal_status_message':
context.Base_translateString(
'Cannot create a Holiday Acquisition without set work time.')})
holiday_acquisition = context.holiday_acquisition_module.newContent(
portal_type="Holiday Acquisition",
......@@ -24,4 +30,7 @@ holiday_acquisition = context.holiday_acquisition_module.newContent(
)
holiday_acquisition.plan()
return holiday_acquisition.Base_redirect('view', keep_items={'portal_status_message': context.Base_translateString('Holiday Acquisition is created')})
return holiday_acquisition.Base_redirect('view',
keep_items={
'portal_status_message':
context.Base_translateString('Holiday Acquisition is created')})
leave_request_list = context.PaySheetTransaction_getRelatedLeaveRequestList()
# I think I dont need this.
if leave_request_list:
return context.Base_redirect('view',
keep_items={
'portal_status_message': context.Base_translateString(
'You have at least one Leave Period for the period.')})
employee = context.getSourceSectionValue()
stop_date = context.getStopDate()
if not stop_date or not context.getStartDate():
return context.Base_redirect('view',
keep_items={
'portal_status_message': context.Base_translateString(
'Please set Start Date and Stop Date.')})
leave_request = context.leave_request_module.newContent(
portal_type="Leave Request",
start_date=context.getStartDate(),
stop_date=stop_date,
title="Leave Request %s For %s " % (stop_date.strftime('%Y%m'), employee.getTitle()),
destination_value = employee,
resource = resource,
)
# Create a period
leave_request.newContent(
portal_type="Leave Request Period",
start_date=leave_request.getStartDate(),
stop_date=leave_request.getStopDate(),
effective_date=leave_request.getStopDate(),
resource=leave_request.getResource(),
quantity=quantity
)
return leave_request.Base_redirect('view',
keep_items={
'portal_status_message':
context.Base_translateString('Leave Request is created')})
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>resource, quantity, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>PaySheetTransaction_addLeaveRequest</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
if context.getStartDate():
return context.portal_catalog(
portal_type= 'Leave Request',
destination_uid=context.getSourceSectionUid(),
**{'delivery.start_date': {'range': 'minngt', "query": (
context.getStartDate(), context.getStopDate())}})
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>PaySheetTransaction_getRelatedLeaveRequestList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
holiday_acquisition = context.getCausalityRelatedValue(
portal_type='Holiday Acquisition')
if holiday_acquisition:
message = context.Base_translateString('Holiday Acquisition is already created')
return holiday_acquisition.Base_redirect('view', keep_items={
'portal_status_message': message})
return context.Base_redirect('view',keep_items={'portal_status_message': \
context.Base_translateString('Holiday Acquisition not found')})
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>**kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>PaySheetTransaction_jumpToHolidayAcquisition</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
leave_request_list = context.PaySheetTransaction_getRelatedLeaveRequestList()
message = context.Base_translateString('Leave Request related:')
if leave_request_list and len(leave_request_list) == 1:
return leave_request_list[0].Base_redirect('view', keep_items={
'portal_status_message': message})
if leave_request_list and len(leave_request_list) > 1:
# Redirect to module
redirect_context = context.getPortalObject().leave_request_module
return redirect_context.Base_redirect('view', keep_items={
'portal_status_message': message,
# We expect that the number is small since there are only 31 possible
# days to take a leave.