Commit 4152bda3 authored by Xiaowu Zhang's avatar Xiaowu Zhang

erp5_production_planning: initialise date and period after created

parent 274abe07
......@@ -34,9 +34,7 @@
</item>
<item>
<key> <string>init_script</string> </key>
<value>
<none/>
</value>
<value> <string>ProductionPlanning_init</string> </value>
</item>
<item>
<key> <string>permission</string> </key>
......
from DateTime import DateTime
from Products.ERP5Type.DateUtils import addToDate
last_production_order = context.portal_catalog.getResultValue(
portal_type = 'Production Order',
simulation_state= ('auto_planned','planned'),
sort_on=(('delivery.start_date', 'descending'),))
start_date = DateTime()
if last_production_order:
stop_date = last_production_order.getStartDate()
else:
stop_date = addToDate(start_date, {'month':1})
context.edit(
start_date=start_date,
stop_date=stop_date,
production_planning_period = context.portal_preferences.getPreferredProductionPlanningPeriod())
<?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>**kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ProductionPlanning_init</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