Commit f15ca709 authored by Cédric Le Ninivin's avatar Cédric Le Ninivin

erp5_pdm: Add Supply_getExpectedDateTuple script

parent 7c2238d8
from Products.ERP5Type.DateUtils import addToDate
supply = context
time_quantity_unit_value = supply.getTimeQuantityUnitValue()
if time_quantity_unit_value is None:
return
time_second_ratio = float(context.getPortalObject().portal_categories.quantity_unit.time.second.getProperty('quantity'))
time_second_conversion_ratio = float(time_quantity_unit_value.getProperty('quantity')) / time_second_ratio
if use_min_delay:
delay_second = supply.getMinDelay() * time_second_conversion_ratio
order_delay_second = supply.getMinOrderDelay() * time_second_conversion_ratio
else:
delay_second = supply.getMaxDelay() * time_second_conversion_ratio
order_delay_second = supply.getMaxOrderDelay() * time_second_conversion_ratio
if effective_date is not None:
start_date = addToDate(effective_date, second=order_delay_second)
stop_date = addToDate(start_date, second=delay_second)
elif start_date is not None:
effective_date = addToDate(start_date, second=-order_delay_second)
stop_date = addToDate(start_date, second=delay_second)
elif stop_date is not None:
start_date = addToDate(stop_date, second=-delay_second)
effective_date = addToDate(start_date, second=-order_delay_second)
else:
effective_date = DateTime().earliestTime()
start_date = addToDate(effective_date, second=order_delay_second)
stop_date = addToDate(start_date, second=delay_second)
return effective_date, start_date, stop_date
<?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>effective_date=None, start_date=None, stop_date=None, use_min_delay=True</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Supply_getExpectedDateTuple</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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