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

2009-05-28 mame

*modify script to properly create variation cells on DeliveryLine

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@27233 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 80ff14bb
...@@ -68,7 +68,7 @@ elif context.getPortalType()== \'Internal Packing List Line\':\n ...@@ -68,7 +68,7 @@ elif context.getPortalType()== \'Internal Packing List Line\':\n
cell_portal_type = \'Internal Packing List Cell\'\n cell_portal_type = \'Internal Packing List Cell\'\n
\n \n
movement_cell_list = context.contentValues(portal_type=cell_portal_type)\n movement_cell_list = context.contentValues(portal_type=cell_portal_type)\n
context.setVariationCategoryList([])\n update_quantity = not context.Movement_isQuantityEditable()\n
base_id = \'movement\'\n base_id = \'movement\'\n
for line in kw.get(\'listbox\'):\n for line in kw.get(\'listbox\'):\n
if line.has_key(\'listbox_key\') and line[\'quantity\'] in (\'\',None):\n if line.has_key(\'listbox_key\') and line[\'quantity\'] in (\'\',None):\n
...@@ -89,27 +89,41 @@ for line in kw.get(\'listbox\'):\n ...@@ -89,27 +89,41 @@ for line in kw.get(\'listbox\'):\n
\n \n
\n \n
if line.has_key("variation_category_list") and line[\'variation_category_list\'] not in(\'\',[]):\n if line.has_key("variation_category_list") and line[\'variation_category_list\'] not in(\'\',[]):\n
new_list = filter(lambda x:(x not in context.getVariationCategoryList()),line["variation_category_list"])\n cell_found = None\n
context.setVariationCategoryList(context.getVariationCategoryList()+new_list)\n for cell in context.getCellValueList(base_id=\'movement\'):\n
if line.has_key("variation_category_list") and line[\'variation_category_list\'] not in(\'\',None):\n if cell.getVariationCategoryList() == line["variation_category_list"]:\n
cell_key = list((line[\'variation_category_list\']))\n cell_found = cell\n
quantity = line[\'quantity\']\n break\n
cell = context.newCell(base_id=base_id, \\\n if cell_found is not None:\n
portal_type=cell_portal_type,*cell_key)\n movement_to_update = cell_found\n
cell.edit(mapped_value_property_list=[\'price\',\'quantity\'],\n else:\n
price=cell.getPrice(), quantity=cell.getQuantity()+quantity,\n if not context.hasInRange(base_id=\'movement\', *line["variation_category_list"]):\n
predicate_category_list=cell_key,\n # update line variation category list, if not already containing this one\n
variation_category_list=cell_key)\n variation_category_list = context.getVariationCategoryList()\n
cell.setAggregateValueList(cell.getAggregateValueList()+[item])\n for variation in line["variation_category_list"]:\n
total_quantity+=line[\'quantity\']\n if variation not in variation_category_list:\n
\n variation_category_list.append(variation)\n
if movement_cell_list ==[]:\n context.setVariationCategoryList(variation_category_list)\n
context.setQuantity(context.getQuantity()+total_quantity)\n movement_to_update = context.newCell(base_id=\'movement\',\n
else:\n portal_type=cell_portal_type,\n
context.setQuantity(total_quantity)\n *line["variation_category_list"])\n
movement_to_update.edit(mapped_value_property_list=(\'quantity\', \'price\'),\n
variation_category_list=line["variation_category_list"],)\n
\n
else:\n
# no variation, we\'ll update the line itself\n
movement_to_update = context\n
\n \n
if context.getVariationCategoryList()==[]: \n if item not in movement_to_update.getAggregateValueList():\n
context.setAggregateValueList(item_list )\n movement_to_update.setAggregateValueSet(\n
movement_to_update.getAggregateValueList() + [item])\n
if update_quantity:\n
if item.getQuantityUnit() != movement_to_update.getQuantityUnit():\n
raise NotImplementedError(\n
\'Quantity unit from the movement differs from quantity\'\n
\' unit on the item\')\n
movement_to_update.setQuantity(\n
movement_to_update.getQuantity() + item.getQuantity())\n
\n \n
return context.Base_redirect(form_id, keep_items=dict(\n return context.Base_redirect(form_id, keep_items=dict(\n
portal_status_message=translateString(\'Items created\')))\n portal_status_message=translateString(\'Items created\')))\n
...@@ -162,6 +176,7 @@ return context.Base_redirect(form_id, keep_items=dict(\n ...@@ -162,6 +176,7 @@ return context.Base_redirect(form_id, keep_items=dict(\n
<string>type</string> <string>type</string>
<string>cell_portal_type</string> <string>cell_portal_type</string>
<string>movement_cell_list</string> <string>movement_cell_list</string>
<string>update_quantity</string>
<string>base_id</string> <string>base_id</string>
<string>_getiter_</string> <string>_getiter_</string>
<string>line</string> <string>line</string>
...@@ -171,14 +186,13 @@ return context.Base_redirect(form_id, keep_items=dict(\n ...@@ -171,14 +186,13 @@ return context.Base_redirect(form_id, keep_items=dict(\n
<string>dict</string> <string>dict</string>
<string>module</string> <string>module</string>
<string>item</string> <string>item</string>
<string>filter</string> <string>cell_found</string>
<string>new_list</string>
<string>list</string>
<string>cell_key</string>
<string>quantity</string>
<string>_apply_</string>
<string>cell</string> <string>cell</string>
<string>_inplacevar_</string> <string>movement_to_update</string>
<string>_apply_</string>
<string>variation_category_list</string>
<string>variation</string>
<string>NotImplementedError</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
139 140
\ No newline at end of file \ No newline at end of file
Internal Packing List Line | item_creation Internal Packing List Line | item_creation
Internal Packing List Line | pagel_item_fast_input
Internal Packing List Line | select_item_fast_input Internal Packing List Line | select_item_fast_input
Internal Packing List | aggregate_item Internal Packing List | aggregate_item
Item Module | create_order Item Module | create_order
......
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