Commit d678051b authored by Nicolas Delaby's avatar Nicolas Delaby

Unify behaviour for all those scripts.

use same script to interrogate tracking_list, then get the object targeted by script
Owner, Site, Resource, or VariationCategories

This will improve consistency in UI because at_date parameter is handled in same way
for all of displayed properties.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@42630 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 3561b2a9
No related merge requests found
<?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>_body</string> </key>
<value> <string>"""Helper script used by many scripts Item_get*(Value|Title) used for UI\n
It helps to improve consistency between all those scripts\n
"""\n
portal = context.getPortalObject()\n
\n
default_at_date = False\n
if at_date is None:\n
default_at_date = True\n
at_date = DateTime()\n
\n
sql_kw = {\'item\': context.getRelativeUrl(),\n
\'at_date\': at_date}\n
\n
affectation_list = portal.portal_simulation.getCurrentTrackingList(**sql_kw)\n
\n
if not affectation_list:\n
if default_at_date:\n
del kw[\'at_date\']\n
affectation_list = portal.portal_simulation.getFutureTrackingList(**sql_kw)\n
\n
return affectation_list\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>at_date=None, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Item_getAffectationList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -50,15 +50,8 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>from DateTime import DateTime\n
portal = context.getPortalObject()\n
\n
last_affectation_list = portal.portal_simulation.getCurrentTrackingList(\n
item=context.getRelativeUrl(), at_date=at_date)\n
\n
if not last_affectation_list:\n
last_affectation_list = portal.portal_simulation.getFutureTrackingList(\n
item=context.getRelativeUrl(), at_date=at_date)\n
<value> <string>portal = context.getPortalObject()\n
last_affectation_list = context.Item_getAffectationList(**kw)\n
\n
if last_affectation_list and last_affectation_list[0].section_uid:\n
return portal.portal_catalog.getObject(last_affectation_list[0].section_uid)\n
......
......@@ -51,22 +51,10 @@
<item>
<key> <string>_body</string> </key>
<value> <string>portal = context.getPortalObject()\n
last_affectation_list = context.Item_getAffectationList(**kw)\n
\n
if at_date is None:\n
at_date = DateTime()\n
\n
last_affectation_list = portal.portal_simulation.getCurrentTrackingList(\n
item=context.getRelativeUrl(), at_date=at_date)\n
\n
if not last_affectation_list:\n
last_affectation_list = portal.portal_simulation.getFutureTrackingList(\n
item=context.getRelativeUrl())\n
if not last_affectation_list:\n
return None\n
\n
if last_affectation_list[0].node_uid is not None:\n
site = portal.portal_catalog.getObject(last_affectation_list[0].node_uid)\n
return site\n
if last_affectation_list and last_affectation_list[0].node_uid is not None:\n
return portal.portal_catalog.getObject(last_affectation_list[0].node_uid)\n
\n
return None\n
</string> </value>
......
......@@ -50,29 +50,10 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>from DateTime import DateTime\n
portal = context.getPortalObject()\n
<value> <string>portal = context.getPortalObject()\n
last_affectation_list = context.Item_getAffectationList(**kw)\n
\n
default_at_date = False\n
if at_date is None:\n
default_at_date = True\n
at_date = DateTime()\n
\n
kw[\'at_date\'] = at_date\n
kw[\'item\'] = context.getRelativeUrl()\n
\n
last_affectation_list = portal.portal_simulation.getCurrentTrackingList(**kw)\n
\n
if kw.get(\'src__\',0):\n
return last_affectation_list\n
\n
if not last_affectation_list:\n
# Falback in Future inventory\n
if default_at_date:\n
del kw[\'at_date\']\n
last_affectation_list = portal.portal_simulation.getFutureTrackingList(**kw)\n
\n
if len(last_affectation_list):\n
if last_affectation_list:\n
last_affectation = last_affectation_list[0]\n
if last_affectation.resource_uid is not None:\n
resource_value = portal.portal_catalog.getObject(last_affectation.resource_uid)\n
......
......@@ -50,27 +50,8 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>from DateTime import DateTime\n
portal = context.getPortalObject()\n
\n
default_at_date = False\n
if at_date is None:\n
default_at_date = True\n
at_date = DateTime()\n
kw[\'at_date\'] = at_date\n
\n
kw[\'item\'] = context.getRelativeUrl()\n
\n
last_affectation_list = portal.portal_simulation.getCurrentTrackingList(**kw)\n
\n
if kw.get(\'src__\',0):\n
return last_affectation_list\n
\n
if not last_affectation_list:\n
# Falback in Future inventory\n
if default_at_date:\n
del kw[\'at_date\']\n
last_affectation_list = portal.portal_simulation.getFutureTrackingList(**kw)\n
<value> <string>portal = context.getPortalObject()\n
last_affectation_list = context.Item_getAffectationList(**kw)\n
\n
if len(last_affectation_list):\n
last_affectation = last_affectation_list[0]\n
......
......@@ -50,21 +50,7 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>from DateTime import DateTime\n
portal = context.getPortalObject()\n
\n
kw[\'at_date\'] = DateTime()\n
kw[\'item\'] = context.getRelativeUrl()\n
\n
last_affectation_list = portal.portal_simulation.getCurrentTrackingList(**kw)\n
\n
if kw.get(\'src__\',0):\n
return last_affectation_list\n
\n
if not last_affectation_list:\n
# Falback in Future inventory\n
last_affectation_list = portal.portal_simulation.getFutureTrackingList(**kw)\n
\n
<value> <string>last_affectation_list = context.Item_getAffectationList(**kw)\n
if len(last_affectation_list):\n
last_affectation = last_affectation_list[0]\n
if last_affectation.delivery_uid is not None:\n
......@@ -78,7 +64,7 @@ return []\n
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>current=1,**kw</string> </value>
<value> <string>**kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -50,29 +50,9 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>from DateTime import DateTime\n
portal = context.getPortalObject()\n
\n
default_at_date = False\n
if at_date is None:\n
default_at_date = True\n
at_date = DateTime()\n
kw[\'at_date\'] = at_date\n
\n
kw[\'item\'] = context.getRelativeUrl()\n
\n
last_affectation_list = portal.portal_simulation.getCurrentTrackingList(**kw)\n
\n
if kw.get(\'src__\',0):\n
return last_affectation_list\n
\n
if not last_affectation_list:\n
# Falback in Future inventory\n
if default_at_date:\n
del kw[\'at_date\']\n
last_affectation_list = portal.portal_simulation.getFutureTrackingList(**kw)\n
\n
if len(last_affectation_list):\n
<value> <string>portal = context.getPortalObject()\n
last_affectation_list = context.Item_getAffectationList(**kw)\n
if last_affectation_list:\n
last_affectation = last_affectation_list[0]\n
if last_affectation.delivery_uid is not None:\n
movement = portal.portal_catalog.getObject(last_affectation.delivery_uid)\n
......@@ -83,7 +63,7 @@ return []\n
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>at_date=None, **kw</string> </value>
<value> <string>**kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
279
\ No newline at end of file
280
\ 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