Commit ff40b534 authored by Łukasz Nowak's avatar Łukasz Nowak

Set stop date according to start date.

It shall be extended always by one month.
parent 29f4194b
......@@ -57,7 +57,6 @@ if params is None:\n
kw = {}\n
\n
from DateTime import DateTime\n
from Products.ERP5Type.DateUtils import getNumberOfDayInMonth\n
\n
last_active_process = context.getLastActiveProcess()\n
if last_active_process is not None and params.get(\'full\', False):\n
......@@ -67,12 +66,9 @@ if last_active_process is not None and params.get(\'full\', False):\n
# register active process in order to have "windows" of last indexed objects\n
context.newActiveProcess()\n
\n
now = DateTime()\n
params.setdefault(\'stop_date\', now + getNumberOfDayInMonth(now))\n
\n
context.getPortalObject().portal_catalog.searchAndActivate(\n
method_id=\'Person_storeOpenOrderJournal\',\n
method_kw={\'indexation_timestamp\': kw.get(\'indexation_timestamp\'), \'tag\': tag, \'stop_date\': params[\'stop_date\']},\n
method_kw={\'indexation_timestamp\': kw.get(\'indexation_timestamp\'), \'tag\': tag, \'stop_date\': params.get(\'stop_date\')},\n
activate_kw={\'tag\': tag, \'priority\': 10},\n
portal_type=\'Person\'\n
)\n
......
......@@ -53,6 +53,7 @@
<value> <string encoding="cdata"><![CDATA[
from DateTime import DateTime\n
from Products.ERP5Type.DateUtils import getNumberOfDayInMonth\n
\n
person = context\n
portal = person.getPortalObject()\n
......@@ -114,19 +115,28 @@ for start_date_tuple in start_date_tuple_list:\n
line.setStartDate(start_date_tuple[1])\n
\n
if stop_date is not None:\n
# check if needed to update\n
need_update = False\n
order = previous_open_sale_order or open_sale_order\n
for line in order.contentValues(portal_type=\'Open Sale Order Line\'):\n
if line.getStopDate() < stop_date:\n
need_update = True\n
break\n
if need_update:\n
if open_sale_order is None:\n
open_sale_order = previous_open_sale_order.Base_createCloneDocument(batch_mode=1)\n
for line in open_sale_order.contentValues(portal_type=\'Open Sale Order Line\'):\n
if line.getStopDate() < stop_date:\n
line.setStopDate(stop_date, activate_kw=activate_kw)\n
next_month = stop_date\n
else:\n
next_month = DateTime() + getNumberOfDayInMonth(DateTime())\n
\n
order = previous_open_sale_order or open_sale_order\n
need_update = False\n
for line in order.contentValues(portal_type=\'Open Sale Order Line\'):\n
if line.getStopDate() is not None and line.getStopDate() < next_month:\n
need_update = True\n
break\n
\n
if need_update:\n
if open_sale_order is None:\n
open_sale_order = previous_open_sale_order.Base_createCloneDocument(batch_mode=1)\n
for line in open_sale_order.contentValues(portal_type=\'Open Sale Order Line\'):\n
old_stop_date = line.getStopDate()\n
if old_stop_date is not None and old_stop_date < next_month:\n
if stop_date is not None:\n
new_stop_date = stop_date\n
else:\n
new_stop_date = old_stop_date + getNumberOfDayInMonth(old_stop_date) \n
line.setStopDate(new_stop_date, activate_kw=activate_kw)\n
\n
for remove_hosting in remove_hosting_list:\n
if remove_hosting in just_added_hosting_kw:\n
......
633
\ No newline at end of file
634
\ 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