Commit d4718344 authored by Nicolas Delaby's avatar Nicolas Delaby

Move out consistency checkings required by fast input from listMethod script of listbox.

Because HTTP redirection is not working during listbox rendering.

Create new script to check consistency of Deliveries which return fast input if checking pass.
Otherwise redirect the user to the Delivery with alert message.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@39971 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f75d6b40
<?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>"""This script check that values fit fast input requirements.\n
If validation succeeds, then form_dialog is returned.\n
Otherwise a message is displayed to the user.\n
"""\n
portal = context.getPortalObject()\n
# Retrieve lines portal type\n
line_portal_type_list = [x for x in context.getTypeInfo().getTypeAllowedContentTypeList() \\\n
if x in portal.getPortalMovementTypeList()]\n
line_portal_type = line_portal_type_list[0]\n
\n
use_list = []\n
# Check if the section and use preference are defined\n
if line_portal_type in context.getPortalSaleTypeList():\n
section_uid = context.getSourceSectionUid()\n
use_list = portal.portal_preferences.getPreferredSaleUseList()\n
elif line_portal_type in portal.getPortalPurchaseTypeList():\n
section_uid = context.getDestinationSectionUid()\n
use_list = portal.portal_preferences.getPreferredPurchaseUseList()\n
elif line_portal_type in portal.getPortalInternalTypeList() + portal.getPortalInventoryMovementTypeList():\n
section_uid = ""\n
use_list = portal.portal_preferences.getPreferredPurchaseUseList() + \\\n
portal.portal_preferences.getPreferredSaleUseList()\n
else:\n
from Products.ERP5Type.Message import translateString\n
return context.Base_redirect(\'view\', keep_items=dict(\n
portal_status_message=translateString(\'Type of document not known to retrieve section.\')))\n
\n
if len(use_list) == 0:\n
from Products.ERP5Type.Message import translateString\n
return context.Base_redirect(\'view\', keep_items=dict(\n
portal_status_message=translateString(\'Use preference must be defined.\')))\n
\n
if section_uid is None:\n
from Products.ERP5Type.Message import translateString\n
return context.Base_redirect(\'view\', keep_items=dict(\n
portal_status_message=translateString(\'Section must be defined.\')))\n
\n
\n
return context.Delivery_viewDeliveryFastInputDialog(*args, **kw)\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>*args, **kw</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>func_code</string> </key>
<value>
<object>
<klass>
<global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>args</string>
<string>kw</string>
<string>_getattr_</string>
<string>context</string>
<string>portal</string>
<string>append</string>
<string>$append0</string>
<string>_getiter_</string>
<string>x</string>
<string>line_portal_type_list</string>
<string>_getitem_</string>
<string>line_portal_type</string>
<string>use_list</string>
<string>section_uid</string>
<string>Products.ERP5Type.Message</string>
<string>translateString</string>
<string>dict</string>
<string>len</string>
<string>None</string>
<string>_apply_</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Delivery_checkConsistencyForDeliveryFastInputDialog</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -2,10 +2,7 @@
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
<tuple/>
</tuple>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
......@@ -75,33 +72,12 @@ if read_document_lines:\n
else:\n
line_list = []\n
\n
use_list = []\n
# Check if the section and use preference are defined\n
if line_portal_type in context.getPortalSaleTypeList():\n
section_uid = context.getSourceSectionUid()\n
use_list = context.portal_preferences.getPreferredSaleUseList()\n
elif line_portal_type in context.getPortalPurchaseTypeList():\n
section_uid = context.getDestinationSectionUid()\n
use_list = context.portal_preferences.getPreferredPurchaseUseList()\n
elif line_portal_type in context.getPortalInternalTypeList() + context.getPortalInventoryMovementTypeList():\n
section_uid = ""\n
use_list = context.portal_preferences.getPreferredPurchaseUseList() + \\\n
context.portal_preferences.getPreferredSaleUseList()\n
else:\n
from Products.ERP5Type.Message import translateString\n
return context.Base_redirect(\'view\', keep_items=dict(\n
portal_status_message=translateString(\'Type of document not known to retrieve section.\')))\n
\n
if len(use_list) == 0:\n
from Products.ERP5Type.Message import translateString\n
return context.Base_redirect(\'view\', keep_items=dict(\n
portal_status_message=translateString(\'Use preference must be defined.\')))\n
\n
if section_uid is None:\n
from Products.ERP5Type.Message import translateString\n
return context.Base_redirect(\'view\', keep_items=dict(\n
portal_status_message=translateString(\'Section must be defined.\')))\n
\n
section_uid = None\n
len_line_list = len(line_list)\n
used_id = [] # list use to make sure we do not generate two line with same id/uid\n
used_id_append = used_id.append\n
......@@ -289,13 +265,9 @@ return result\n
<string>_getitem_</string>
<string>line_portal_type</string>
<string>line_list</string>
<string>use_list</string>
<string>section_uid</string>
<string>Products.ERP5Type.Message</string>
<string>translateString</string>
<string>dict</string>
<string>len</string>
<string>None</string>
<string>len</string>
<string>len_line_list</string>
<string>used_id</string>
<string>used_id_append</string>
......
999
\ No newline at end of file
1002
\ 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