Commit 06d8c679 authored by Aurel's avatar Aurel

do not allow to open a counter date if we are on a not working day

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@24456 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 7a3534d9
...@@ -81,6 +81,7 @@ if site_uid is None:\n ...@@ -81,6 +81,7 @@ if site_uid is None:\n
counter_date_list = [x.getObject() for x in counter_date.portal_catalog(portal_type=\'Counter Date\',site_uid=site_uid,simulation_state=\'open\')]\n counter_date_list = [x.getObject() for x in counter_date.portal_catalog(portal_type=\'Counter Date\',site_uid=site_uid,simulation_state=\'open\')]\n
for other_counter in counter_date_list:\n for other_counter in counter_date_list:\n
if other_counter.getUid()!=counter_date.getUid():\n if other_counter.getUid()!=counter_date.getUid():\n
counter_date.log("opened counter date is", other_counter.getPath())\n
msg = Message(domain=\'ui\',message="Sorry, there is already a counter date opened")\n msg = Message(domain=\'ui\',message="Sorry, there is already a counter date opened")\n
raise ValidationFailed (msg,)\n raise ValidationFailed (msg,)\n
\n \n
...@@ -92,11 +93,25 @@ start_date = counter_date.getStartDate()\n ...@@ -92,11 +93,25 @@ start_date = counter_date.getStartDate()\n
from DateTime import DateTime\n from DateTime import DateTime\n
now = DateTime()\n now = DateTime()\n
\n \n
# Check it is a working day\n
if len(getattr(context.getPortalObject(), \'not_working_days\', "")) == 0:\n
pass\n
else:\n
not_working_day_list = getattr(context.getPortalObject(), \'not_working_days\').split(" ")\n
if start_date.Day().lower() in not_working_day_list:\n
msg = Message(domain=\'ui\',message="Sorry, you cannot open the date on not working days")\n
raise ValidationFailed (msg,)\n
\n
\n
# Check it is today\n
check_date_is_today = state_change.kwargs.get(\'check_date_is_today\', 1)\n check_date_is_today = state_change.kwargs.get(\'check_date_is_today\', 1)\n
if check_date_is_today and now.Date() != start_date.Date():\n if check_date_is_today and now.Date() != start_date.Date():\n
msg = Message(domain=\'ui\',message="Sorry, the date is not today")\n msg = Message(domain=\'ui\',message="Sorry, the date is not today")\n
raise ValidationFailed (msg,)\n raise ValidationFailed (msg,)\n
\n \n
\n
\n
\n
if listbox is not None:\n if listbox is not None:\n
for line in listbox:\n for line in listbox:\n
if line["choice"] == "open":\n if line["choice"] == "open":\n
...@@ -185,12 +200,14 @@ counter_date.setReference(reference)\n ...@@ -185,12 +200,14 @@ counter_date.setReference(reference)\n
<string>start_date</string> <string>start_date</string>
<string>DateTime</string> <string>DateTime</string>
<string>now</string> <string>now</string>
<string>len</string>
<string>getattr</string>
<string>context</string>
<string>not_working_day_list</string>
<string>check_date_is_today</string> <string>check_date_is_today</string>
<string>line</string> <string>line</string>
<string>context</string>
<string>counter</string> <string>counter</string>
<string>previous_reference</string> <string>previous_reference</string>
<string>len</string>
<string>previous_counter_date</string> <string>previous_counter_date</string>
<string>int</string> <string>int</string>
<string>reference</string> <string>reference</string>
......
457 459
\ No newline at end of file \ No newline at end of file
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