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

2009-05-19 mame

*modified script to create items even if only reference or title is defined

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@27066 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 49821c11
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
item_list = []\n item_list = []\n
request = context.REQUEST\n request = context.REQUEST\n
total_quantity = 0.0\n total_quantity = 0.0\n
type = request.get("field_my_type")\n type = request.get("field_your_type")\n
if context.getPortalType()==\'Purchase Packing List Line\':\n if context.getPortalType()==\'Purchase Packing List Line\':\n
cell_portal_type = \'Purchase Packing List Cell\'\n cell_portal_type = \'Purchase Packing List Cell\'\n
elif context.getPortalType()==\'Purchase Order Line\' :\n elif context.getPortalType()==\'Purchase Order Line\' :\n
...@@ -70,30 +70,32 @@ context.setVariationCategoryList([])\n ...@@ -70,30 +70,32 @@ context.setVariationCategoryList([])\n
context.setAggregateValueList([])\n context.setAggregateValueList([])\n
base_id = \'movement\'\n base_id = \'movement\'\n
for line in kw.get(\'listbox\'):\n for line in kw.get(\'listbox\'):\n
if not (line[\'title\']):\n if line.has_key(\'listbox_key\') and line[\'quantity\'] in (\'\',None):\n
continue\n request.set(\'portal_status_message\', \n
module = context.getDefaultModule(\'Item\')\n Base_translateString(\'Please Define Quantity for Item Defined On Line %s\'%line[\'listbox_key\']))\n
item = module.newContent(portal_type=\'Item\',\n if line.has_key(\'listbox_key\') and (line[\'title\'] or line[\'reference\'] not in (\'\', None)):\n
module = context.getDefaultModule(type)\n
item = module.newContent(portal_type=type,\n
title=line[\'title\'],\n title=line[\'title\'],\n
reference=line[\'reference\'],\n reference=line[\'reference\'],\n
quantity=line[\'quantity\'])\n quantity=line[\'quantity\'])\n
item.validate()\n item.validate()\n
item_list.append(item) \n item_list.append(item) \n
\n \n
\n \n
if line.has_key("variation_category_list") and line[\'variation_category_list\'] not in(\'\',[]) and [line[\'variation_category_list\'][i] not in context.getVariationCategoryList() for i in range(0,(len(line[\'variation_category_list\'])-1))][0]:\n if line.has_key("variation_category_list") and line[\'variation_category_list\'] not in(\'\',[]) and [line[\'variation_category_list\'][i] not in context.getVariationCategoryList() for i in range(0,(len(line[\'variation_category_list\'])-1))][0]:\n
context.setVariationCategoryList(context.getVariationCategoryList() + list((line[\'variation_category_list\'])))\n context.setVariationCategoryList(context.getVariationCategoryList() + list((line[\'variation_category_list\'])))\n
if line.has_key("variation_category_list") and line[\'variation_category_list\'] not in(\'\',None):\n if line.has_key("variation_category_list") and line[\'variation_category_list\'] not in(\'\',None):\n
cell_key = list((line[\'variation_category_list\']))\n cell_key = list((line[\'variation_category_list\']))\n
quantity = line[\'quantity\']\n quantity = line[\'quantity\']\n
cell = context.newCell(base_id=base_id, \\\n cell = context.newCell(base_id=base_id, \\\n
portal_type=cell_portal_type,*cell_key)\n portal_type=cell_portal_type,*cell_key)\n
cell.edit(mapped_value_property_list=[\'price\',\'quantity\'],\n cell.edit(mapped_value_property_list=[\'price\',\'quantity\'],\n
price=cell.getPrice(), quantity=quantity,\n price=cell.getPrice(), quantity=quantity,\n
predicate_category_list=cell_key,\n predicate_category_list=cell_key,\n
variation_category_list=cell_key)\n variation_category_list=cell_key)\n
cell.setAggregateValue(item)\n cell.setAggregateValue(item)\n
total_quantity+=line[\'quantity\']\n total_quantity+=line[\'quantity\']\n
\n \n
if movement_cell_list ==[]:\n if movement_cell_list ==[]:\n
context.setQuantity(context.getQuantity()+total_quantity)\n context.setQuantity(context.getQuantity()+total_quantity)\n
...@@ -158,6 +160,8 @@ return context.Base_redirect(form_id, keep_items=dict(\n ...@@ -158,6 +160,8 @@ return context.Base_redirect(form_id, keep_items=dict(\n
<string>_getiter_</string> <string>_getiter_</string>
<string>line</string> <string>line</string>
<string>_getitem_</string> <string>_getitem_</string>
<string>None</string>
<string>Base_translateString</string>
<string>module</string> <string>module</string>
<string>item</string> <string>item</string>
<string>append</string> <string>append</string>
...@@ -166,7 +170,6 @@ return context.Base_redirect(form_id, keep_items=dict(\n ...@@ -166,7 +170,6 @@ return context.Base_redirect(form_id, keep_items=dict(\n
<string>len</string> <string>len</string>
<string>i</string> <string>i</string>
<string>list</string> <string>list</string>
<string>None</string>
<string>cell_key</string> <string>cell_key</string>
<string>quantity</string> <string>quantity</string>
<string>_apply_</string> <string>_apply_</string>
......
74 76
\ No newline at end of file \ 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