Commit afbd18a0 authored by Mame Coumba Sall's avatar Mame Coumba Sall

2009-06-11 mame

*add condition on script to avoid creating items with the same reference
*checkConsistency before validation of item

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@27519 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent ccda9213
......@@ -90,15 +90,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
\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
raise NotImplementedError(\n
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
......@@ -224,9 +232,11 @@ 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>NotImplementedError</string>
<string>module</string>
<string>_apply_</string>
<string>item</string>
<string>line_variation_category_list</string>
<string>variation</string>
<string>cell_found</string>
......@@ -237,7 +247,6 @@ return context.Base_redirect(form_id, keep_items=dict(\n
<string>movement</string>
<string>quantity</string>
<string>len</string>
<string>NotImplementedError</string>
<string>_inplacevar_</string>
</tuple>
</value>
......
......@@ -15,6 +15,12 @@
<dictionary/>
</value>
</item>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>scripts</string> </value>
......
<?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>object = state_change[\'object\']\n
object.Base_checkConsistency()\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>state_change</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>state_change</string>
<string>_getitem_</string>
<string>object</string>
<string>_getattr_</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>checkConsistency</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -45,7 +45,7 @@
</item>
<item>
<key> <string>script_name</string> </key>
<value> <string></string> </value>
<value> <string>checkConsistency</string> </value>
</item>
<item>
<key> <string>title</string> </key>
......
167
\ No newline at end of file
168
\ 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