Commit 8eaf6e96 authored by Łukasz Nowak's avatar Łukasz Nowak

Simplify and optimise conditions.

parent f37e7e27
......@@ -54,6 +54,12 @@
from DateTime import DateTime\n
\n
tag = \'%s_updateOpenOrder\' % person.getUid()\n
kw = {\'activate_kw\': {\'tag\': tag}}\n
if portal.portal_activities.countMessageWithTag(tag) > 0:\n
# nothing to do\n
return\n
\n
if remove_id_list is None:\n
remove_id_list = []\n
\n
......@@ -65,11 +71,9 @@ previous_open_sale_order = portal.portal_catalog.getResultValue(\n
validation_state="validated")\n
\n
now = DateTime()\n
tag = \'%s_updateOpenOrder\' % person.getUid()\n
kw = {\'activate_kw\': {\'tag\': tag}}\n
if portal.portal_activities.countMessageWithTag(tag) == 0:\n
open_sale_order = None\n
if previous_open_sale_order is None:\n
\n
open_sale_order = None\n
if previous_open_sale_order is None:\n
open_sale_order = portal.open_sale_order_module.newContent(\n
source=\'organisation_module/vifib_internet\',\n
source_section=\'organisation_module/vifib_internet\',\n
......@@ -80,11 +84,11 @@ if portal.portal_activities.countMessageWithTag(tag) == 0:\n
specialise=\'sale_trade_condition_module/vifib_trade_condition\',\n
title="ViFiB Open Order",\n
**kw)\n
for remove_id in remove_id_list:\n
for remove_id in remove_id_list:\n
if open_sale_order is None:\n
open_sale_order = previous_open_sale_order.Base_createCloneDocument(batch_mode=1)\n
open_sale_order.deleteContent(remove_id)\n
if add_kw is not None:\n
if add_kw is not None:\n
add_tag = add_kw.pop(\'tag\', None)\n
add_kw.update(kw)\n
if open_sale_order is None:\n
......@@ -93,7 +97,7 @@ if portal.portal_activities.countMessageWithTag(tag) == 0:\n
if add_tag is not None:\n
# lock by passed tag\n
open_sale_order.activate(tag=add_tag, after_tag=kw[\'activate_kw\'][\'tag\']).getId()\n
if stop_date is not None:\n
if stop_date is not None:\n
# check if needed to update\n
need_update = False\n
for line in previous_open_sale_order.contentValues(portal_type=\'Open Sale Order Line\'):\n
......@@ -106,9 +110,9 @@ if portal.portal_activities.countMessageWithTag(tag) == 0:\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, **kw)\n
if previous_open_sale_order is not None and open_sale_order is not None:\n
if previous_open_sale_order is not None and open_sale_order is not None:\n
previous_open_sale_order.setExpirationDate(now, **kw)\n
if open_sale_order is not None:\n
if open_sale_order is not None:\n
open_sale_order.setEffectiveDate(now, **kw)\n
open_sale_order.order(**kw)\n
open_sale_order.validate(**kw)\n
......
622
\ No newline at end of file
623
\ 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