Commit 5f9f186d authored by Mame Coumba Sall's avatar Mame Coumba Sall

2009-07-03 mame

*create new script to set value of reference
*modified validator so that EAN13 code is only completed when the specific properties exist
*modified script so that it searches for item reference before creating the item

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@27913 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent d3811868
......@@ -91,14 +91,23 @@ base_id = \'movement\'\n
for line in kw.get(\'listbox\'):\n
\n
if line.has_key(\'listbox_key\') and (line[\'title\'] or line[\'reference\'] not in (\'\', None)):\n
module = context.getDefaultModule(item_portal_type)\n
item = module.newContent(portal_type=item_portal_type,\n
title=line[\'title\'],\n
reference = line["reference"],\n
quantity=line[\'quantity\'],\n
quantity_unit=context.getQuantityUnit(),\n
**item_property_dict)\n
item.validate()\n
item = context.portal_catalog.getResultValue(\n
portal_type=\'Item\',\n
reference=line[\'reference\'])\n
if item is not None:\n
msg = translateString("Reference Defined On Line ${line_id} already exists",\n
mapping={\'line_id\': line[\'listbox_key\']})\n
return context.Base_redirect(form_id, keep_items=dict(\n
portal_status_message=msg))\n
else:\n
module = context.getDefaultModule(item_portal_type)\n
item = module.newContent(portal_type=item_portal_type,\n
title=line[\'title\'],\n
reference = line["reference"],\n
quantity=line[\'quantity\'],\n
quantity_unit=context.getQuantityUnit(),\n
**item_property_dict)\n
item.validate()\n
\n
line_variation_category_list = []\n
for variation in (\n
......@@ -226,9 +235,10 @@ return context.Base_redirect(form_id, keep_items=dict(\n
<string>base_id</string>
<string>line</string>
<string>None</string>
<string>item</string>
<string>msg</string>
<string>module</string>
<string>_apply_</string>
<string>item</string>
<string>line_variation_category_list</string>
<string>variation</string>
<string>cell_found</string>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
<tuple/>
</tuple>
</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>return request.get(\'field_listbox_reference_%s\' % cell.uid)\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>request</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>1</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>request</string>
<string>_getattr_</string>
<string>cell</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>DeliveryLine_setDefaultReference</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -55,16 +55,20 @@
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
if editor and len(request.get("field_listbox_reference_%s" % request.cell.uid))<=13:\n
dialog = getattr(context, dialog_id)\n
if dialog.has_field(\'your_item_extra_property_list\') and editor and len(request.get("field_listbox_reference_%s" % request.cell.uid))<=6:\n
reference = "%s%s" % (request.get("field_your_prefix_reference"), request.get(\'field_listbox_reference_%s\' % request.cell.uid).zfill(6)) \n
test_result = request.cell.Base_validateEan13Code(reference,request)\n
\n
if test_result ==True:\n
request.form["field_listbox_reference_%s" % request.cell.uid] = reference\n
request.set("field_listbox_reference_%s" % request.cell.uid,reference)\n
result = [x.getObject() for x in context.portal_catalog(portal_type = request.get("field_your_type"),\n
reference= reference)]\n
if (result !=[] or test_result ==False ):\n
return False\n
\n
elif test_result == False:\n
return False \n
return True\n
......@@ -78,7 +82,7 @@ return True\n
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>editor, request</string> </value>
<value> <string>editor, request,dialog_id=\'DeliveryLine_viewItemCreationDialog\'</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
......@@ -98,7 +102,7 @@ return True\n
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>2</int> </value>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
......@@ -106,8 +110,12 @@ return True\n
<tuple>
<string>editor</string>
<string>request</string>
<string>len</string>
<string>dialog_id</string>
<string>getattr</string>
<string>context</string>
<string>dialog</string>
<string>_getattr_</string>
<string>len</string>
<string>reference</string>
<string>test_result</string>
<string>True</string>
......@@ -115,7 +123,6 @@ return True\n
<string>append</string>
<string>$append0</string>
<string>_getiter_</string>
<string>context</string>
<string>x</string>
<string>result</string>
<string>False</string>
......@@ -130,7 +137,9 @@ return True\n
<item>
<key> <string>func_defaults</string> </key>
<value>
<none/>
<tuple>
<string>DeliveryLine_viewItemCreationDialog</string>
</tuple>
</value>
</item>
<item>
......
......@@ -350,10 +350,6 @@
<string>reference</string>
<string>Reference</string>
</tuple>
<tuple>
<string>quantity</string>
<string>Quantity</string>
</tuple>
<tuple>
<string>line_variation_category_list</string>
<string>Variation 1</string>
......@@ -366,6 +362,10 @@
<string>tab_variation_category_list</string>
<string>Variation 3</string>
</tuple>
<tuple>
<string>quantity</string>
<string>Quantity</string>
</tuple>
</list>
</value>
</item>
......@@ -413,10 +413,6 @@
<string>reference</string>
<string>Reference</string>
</tuple>
<tuple>
<string>quantity</string>
<string>Quantity</string>
</tuple>
<tuple>
<string>line_variation_category_list</string>
<string>Variation 1</string>
......@@ -429,6 +425,10 @@
<string>tab_variation_category_list</string>
<string>Variation 3</string>
</tuple>
<tuple>
<string>quantity</string>
<string>Quantity</string>
</tuple>
</list>
</value>
</item>
......
......@@ -13,6 +13,7 @@
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>default</string>
<string>display_maxwidth</string>
<string>display_width</string>
<string>external_validator</string>
......@@ -66,6 +67,24 @@
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>default</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>display_maxwidth</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_width</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
......@@ -78,6 +97,10 @@
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
......@@ -85,6 +108,10 @@
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_maxwidth</string> </key>
<value> <int>13</int> </value>
......@@ -96,7 +123,7 @@
<item>
<key> <string>external_validator</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
......@@ -122,6 +149,22 @@
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: cell.DeliveryLine_setDefaultReference()</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<tuple>
<global name="Method" module="Products.Formulator.MethodField"/>
......
173
\ No newline at end of file
174
\ 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