Commit 185285c4 authored by Georgios Dagkakis's avatar Georgios Dagkakis

erp5_calendar: Make Leave Request more user-friendly in parameterisation and appearance.

Follow a simple / non-simple approach, like for Task and its lines.

In default case, user would need only one Leave Request Period, which
can be edited directly on LeaveRequest_view. So, in this case, hide the Listbox
containing the Leave Request Periods and have default_leave_request_period
being created / edited on background, which will acquire quantity, resource, start_date and stop_date
from what is set at the view of the Parent.

In case one or more Leave Request Period are added manually, user would get
listbox with sub-objects, and editing should be done directly on them, i.e. fields like
my_default_leave_request_period_start_date will be disabled from LeaveRequest_view.

Additionally, now Leave Request has it's own:
- start_date: equal to the minimum start_date of all Leave Request Periods
- stop_date: equal to the maximum stop_date of all Leave Request Periods

These values are set by interaction on Leave Request Period, triggered on
_setStartDate, _setStopDate. This helps so that leave_request_module listbox
can have sortable dates.

Commit contains also <a href="https://lab.nexedi.com/georgios.dagkakis/erp5/blob/leave_request/product/ERP5/tests/testCalendar.py#L1626">test</a> that should make it easier to understand.

Test results <a href="https://nexedi.erp5.net/test_result_module/20171113-20E90B8F">here</a>

@seb we have talked on this and @cedric.leninivin I know you dealt with Leave Requests. Who else should be notified?





/reviewed-on nexedi/erp5!493
parent e965727e
<property_sheet_list>
<portal_type id="Leave Request">
<item>LeaveRequest</item>
</portal_type>
<portal_type id="System Preference">
<item>CalendarPreference</item>
</portal_type>
......
......@@ -13,11 +13,11 @@
</chain>
<chain>
<type>Leave Request</type>
<workflow>edit_workflow, leave_request_workflow</workflow>
<workflow>edit_workflow, leave_request_interaction_workflow, leave_request_workflow</workflow>
</chain>
<chain>
<type>Leave Request Period</type>
<workflow>edit_workflow</workflow>
<workflow>edit_workflow, leave_request_interaction_workflow</workflow>
</chain>
<chain>
<type>Presence Request</type>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Property Sheet" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_count</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_mt_index</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>_tree</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>LeaveRequest</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Property Sheet</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Length" module="BTrees.Length"/>
</pickle>
<pickle> <int>0</int> </pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Acquired Property" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>acquisition_accessor_id</string> </key>
<value> <string>getLeaveRequestPeriodValue</string> </value>
</item>
<item>
<key> <string>acquisition_base_category</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>acquisition_mask_value</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>acquisition_object_id</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>alt_accessor_id</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>elementary_type/content</string>
</tuple>
</value>
</item>
<item>
<key> <string>content_acquired_property_id</string> </key>
<value>
<tuple>
<string>quantity</string>
<string>resource</string>
<string>start_date</string>
<string>stop_date</string>
</tuple>
</value>
</item>
<item>
<key> <string>content_portal_type</string> </key>
<value> <string>python: (\'Leave Request Period\',)</string> </value>
</item>
<item>
<key> <string>content_translation_acquired_property_id</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>The default Leave Request Period</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>leave_request_period_property</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Acquired Property</string> </value>
</item>
<item>
<key> <string>storage_id</string> </key>
<value> <string>default_leave_request_period</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -116,6 +116,14 @@
<string>Calendar_getDestinationSubordinationTitle</string>
<string>Organisation</string>
</tuple>
<tuple>
<string>delivery.start_date</string>
<string>Start Date</string>
</tuple>
<tuple>
<string>delivery.stop_date</string>
<string>Stop Date</string>
</tuple>
<tuple>
<string>description</string>
<string>Description</string>
......
return [
x for x in context.objectIds(portal_type=("Leave Request Period"))
] in ([], ['default_leave_request_period'])
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<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>LeaveRequest_isSimple</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -83,6 +83,7 @@
<list>
<string>listbox_start_date</string>
<string>listbox_stop_date</string>
<string>listbox_quantity</string>
</list>
</value>
</item>
......@@ -91,6 +92,9 @@
<value>
<list>
<string>my_title</string>
<string>my_destination_title</string>
<string>my_default_leave_request_period_quantity</string>
<string>my_default_leave_request_period_resource</string>
</list>
</value>
</item>
......@@ -98,7 +102,10 @@
<key> <string>right</string> </key>
<value>
<list>
<string>my_destination_title</string>
<string>my_start_date</string>
<string>my_stop_date</string>
<string>my_default_leave_request_period_start_date</string>
<string>my_default_leave_request_period_stop_date</string>
<string>my_translated_simulation_state_title</string>
</list>
</value>
......
......@@ -10,11 +10,14 @@
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>title</string>
<string>selection_name</string>
<string>portal_types</string>
<string>columns</string>
<string>default_params</string>
<string>editable_columns</string>
<string>enabled</string>
<string>list_action</string>
<string>portal_types</string>
<string>selection_name</string>
<string>title</string>
</list>
</value>
</item>
......@@ -56,6 +59,20 @@
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>default_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable_columns</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
......@@ -64,10 +81,26 @@
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>list_action</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>portal_types</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>selection_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
......@@ -75,12 +108,66 @@
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>columns</string> </key>
<value>
<list>
<tuple>
<string>int_index</string>
<string>Int Index</string>
</tuple>
<tuple>
<string>title</string>
<string>Title</string>
</tuple>
<tuple>
<string>quantity</string>
<string>Quantity</string>
</tuple>
<tuple>
<string>start_date</string>
<string>Start Date</string>
</tuple>
<tuple>
<string>stop_date</string>
<string>Stop Date</string>
</tuple>
<tuple>
<string>translated_portal_type</string>
<string>Type</string>
</tuple>
</list>
</value>
</item>
<item>
<key> <string>default_params</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>editable_columns</string> </key>
<value>
<list>
<tuple>
<string>start_date</string>
<string>Start Date</string>
</tuple>
<tuple>
<string>stop_date</string>
<string>Stop Date</string>
</tuple>
<tuple>
<string>quantity</string>
<string>Quantity</string>
</tuple>
</list>
</value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>listbox</string> </value>
......@@ -122,4 +209,17 @@
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: not here.LeaveRequest_isSimple()</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -9,9 +9,7 @@
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>editable</string>
</list>
<list/>
</value>
</item>
<item>
......@@ -71,10 +69,6 @@
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>editable</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_start_date</string> </value>
......
......@@ -9,9 +9,7 @@
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>editable</string>
</list>
<list/>
</value>
</item>
<item>
......@@ -71,10 +69,6 @@
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>editable</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_stop_date</string> </value>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>enabled</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_default_leave_request_period_quantity</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>extra_context</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>enabled</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>extra_context</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>enabled</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>extra_context</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_quantity</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Calendar_viewFieldLibrary</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: here.LeaveRequest_isSimple()</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>enabled</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_default_leave_request_period_resource</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>enabled</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>enabled</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_absence_resource</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Calendar_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: here.LeaveRequest_isSimple()</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="InteractionWorkflowDefinition" module="Products.ERP5.InteractionWorkflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>creation_guard</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>groups</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>leave_request_interaction_workflow</string> </value>
</item>
<item>
<key> <string>manager_bypass</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Leave Request Interaction Workflow</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Interaction" module="Products.ERP5.Interaction"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_mapping</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>interactions</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="InteractionDefinition" module="Products.ERP5.Interaction"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>actbox_category</string> </key>
<value> <string>workflow</string> </value>
</item>
<item>
<key> <string>actbox_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>actbox_url</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>activate_script_name</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>after_script_name</string> </key>
<value>
<list>
<string>LeaveRequestPeriod_setLeaveRequestDate</string>
</list>
</value>
</item>
<item>
<key> <string>before_commit_script_name</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>guard</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>LeaveRequestPeriod_setLeaveRequestDate</string> </value>
</item>
<item>
<key> <string>method_id</string> </key>
<value>
<list>
<string>_setStartDate</string>
<string>_setStopDate</string>
</list>
</value>
</item>
<item>
<key> <string>once_per_transaction</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>portal_type_filter</string> </key>
<value>
<list>
<string>Leave Request Period</string>
</list>
</value>
</item>
<item>
<key> <string>portal_type_group_filter</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>script_name</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>temporary_document_disallowed</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>trigger_type</string> </key>
<value> <int>2</int> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Scripts" module="Products.DCWorkflow.Scripts"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_mapping</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>scripts</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
leave_request = state_change['object'].getParentValue()
leave_request_period_list = leave_request.objectValues(
portal_type='Leave Request Period',
)
leave_request.setStartDate(
min([x.getStartDate() for x in leave_request_period_list])
)
leave_request.setStopDate(
max([x.getStopDate() for x in leave_request_period_list])
)
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<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>state_change</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>LeaveRequestPeriod_setLeaveRequestDate</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Variables" module="Products.DCWorkflow.Variables"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_mapping</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>variables</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Worklists" module="Products.DCWorkflow.Worklists"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_mapping</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>worklists</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
Leave Request | LeaveRequest
System Preference | CalendarPreference
\ No newline at end of file
......@@ -6,7 +6,9 @@ Group Calendar | group_calendar_workflow
Group Presence Period | edit_workflow
Group Presence Period | group_calendar_interaction_workflow
Leave Request Period | edit_workflow
Leave Request Period | leave_request_interaction_workflow
Leave Request | edit_workflow
Leave Request | leave_request_interaction_workflow
Leave Request | leave_request_workflow
Presence Request Period | edit_workflow
Presence Request | edit_workflow
......
LeaveRequest
\ No newline at end of file
group_calendar_interaction_workflow
group_calendar_workflow
leave_request_interaction_workflow
leave_request_workflow
presence_request_workflow
\ No newline at end of file
......@@ -1623,6 +1623,99 @@ class TestCalendar(ERP5ReportTestCase):
**{'calendar_period_type/type2': 2.0,
'calendar_period_type/type3': 1.5,})
def test_LeaveRequest_defaultLeaveRequestPeriod(self):
'''
Check check how default_leave_request_period is created and when
fields of LeaveRequest_view are visible or not
'''
default_start_date = DateTime('2018/01/01')
default_stop_date = DateTime('2018/01/03')
extra_start_date = DateTime('2018/01/05')
extra_stop_date = DateTime('2018/01/08')
default_quantity = 2.0
def checkDisplayedAsSimple():
self.assertEqual(
my_default_leave_request_period_start_date.get_value("enabled"),
True,
)
self.assertEqual(
my_default_leave_request_period_stop_date.get_value("enabled"),
True,
)
self.assertEqual(my_start_date.get_value("enabled"), False)
self.assertEqual(my_start_date.get_value("enabled"), False)
self.assertEqual(listbox.get_value("enabled"), False)
# Add a Leave Request, we should have no sub-objects and it should be
# displayed as simple (no listbox and fields to be edited on Delivery)
leave_request = self.portal.leave_request_module.newContent()
LeaveRequest_view = leave_request.LeaveRequest_view
my_default_leave_request_period_start_date = LeaveRequest_view.\
my_default_leave_request_period_start_date
my_default_leave_request_period_stop_date = LeaveRequest_view.\
my_default_leave_request_period_stop_date
my_start_date = LeaveRequest_view.my_start_date
my_stop_date = LeaveRequest_view.my_stop_date
listbox = LeaveRequest_view.listbox
checkDisplayedAsSimple()
self.assertEqual(
len(leave_request.objectValues(portal_type='Leave Request Period')), 0
)
# Edit properties, default_leave_request_period should be created, yet
# Leave Request is still displayed as simple
leave_request.edit(
default_leave_request_period_start_date=default_start_date,
default_leave_request_period_stop_date=default_stop_date,
default_leave_request_period_quantity=default_quantity,
)
checkDisplayedAsSimple()
leave_request_period_list = leave_request.objectValues(
portal_type='Leave Request Period'
)
self.assertEqual(len(leave_request_period_list), 1)
default_leave_request_period = leave_request_period_list[0]
self.assertEqual(
default_leave_request_period.getId(), 'default_leave_request_period'
)
self.assertEqual(default_leave_request_period.getStartDate(), default_start_date)
self.assertEqual(default_leave_request_period.getStopDate(), default_stop_date)
self.assertEqual(default_leave_request_period.getQuantity(), default_quantity)
self.assertEqual(leave_request.getStartDate(), default_start_date)
self.assertEqual(leave_request.getStopDate(), default_stop_date)
extra_leave_request_period = leave_request.newContent(
portal_type = 'Leave Request Period',
)
extra_leave_request_period.edit(
start_date=extra_start_date,
stop_date=extra_stop_date,
quantity=1.0,
)
self.assertEqual(
len(leave_request.objectValues(portal_type='Leave Request Period')), 2
)
# Since we have more than 1 Leave Request Periods, now we get the non-simple
# display (with listbox and not fields to be edited on Delivery)
self.assertEqual(
my_default_leave_request_period_start_date.get_value("enabled"),
False,
)
self.assertEqual(
my_default_leave_request_period_stop_date.get_value("enabled"),
False,
)
self.assertEqual(my_start_date.get_value("enabled"), True)
self.assertEqual(my_start_date.get_value("enabled"), True)
self.assertEqual(listbox.get_value("enabled"), True)
# yet, start and stop dates are not editable in Delivery level
# and they are defined by the movement values
self.assertEqual(my_start_date.get_value("editable"), 0)
self.assertEqual(my_start_date.get_value("editable"), 0)
self.assertEqual(leave_request.getStartDate(), default_start_date)
self.assertEqual(leave_request.getStopDate(), extra_stop_date)
def test_suite():
suite = unittest.TestSuite()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment