Commit 1be89d81 authored by Jérome Perrin's avatar Jérome Perrin

fast inputs to create or select items now update all movements to set the...

fast inputs to create or select items now update all movements to set the quantities to the sum of selected item quantities

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@27251 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 3f5f2a04
......@@ -53,7 +53,9 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>from Products.ERP5Type.Message import translateString\n
<value> <string encoding="cdata"><![CDATA[
from Products.ERP5Type.Message import translateString\n
item_list = []\n
request = context.REQUEST\n
total_quantity = 0.0\n
......@@ -68,16 +70,17 @@ elif context.getPortalType()== \'Internal Packing List Line\':\n
cell_portal_type = \'Internal Packing List Cell\'\n
\n
movement_cell_list = context.contentValues(portal_type=cell_portal_type)\n
update_quantity = not context.Movement_isQuantityEditable()\n
base_id = \'movement\'\n
\n
for line in kw.get(\'listbox\'):\n
if line.has_key(\'listbox_key\') and line[\'quantity\'] in (\'\',None):\n
msg = translateString("Please Define Quantity for Item Defined On Line ${line_id}",\n
mapping={\'line_id\': line[\'listbox_key\']})\n
raise NotImplementedError(\n
msg)\n
\n
if line.has_key(\'listbox_key\') and (line[\'title\'] or line[\'reference\'] not in (\'\', None)):\n
\n
if line[\'quantity\'] in (\'\',None):\n
msg = translateString("Please Define Quantity for Item Defined On Line ${line_id}",\n
mapping={\'line_id\': line[\'listbox_key\']})\n
raise NotImplementedError(msg)\n
\n
module = context.getDefaultModule(type)\n
item = module.newContent(portal_type=type,\n
title=line[\'title\'],\n
......@@ -114,13 +117,31 @@ for line in kw.get(\'listbox\'):\n
if item not in movement_to_update.getAggregateValueList():\n
movement_to_update.setAggregateValueSet(\n
movement_to_update.getAggregateValueList() + [item])\n
if update_quantity:\n
movement_to_update.setQuantity(\n
movement_to_update.getQuantity() + item.getQuantity())\n
\n
\n
update_quantity = not context.Movement_isQuantityEditable()\n
if update_quantity:\n
if context.isMovement():\n
movement_list = context,\n
else:\n
movement_list = context.getCellValueList(base_id=\'movement\')\n
for movement in movement_list:\n
quantity = 0\n
item_list = movement.getAggregateValueList()\n
for item in item_list:\n
if item.getQuantityUnit() != movement.getQuantityUnit():\n
if len(item_list) > 1:\n
raise NotImplementedError(\n
\'Quantity unit from the movement differs from quantity\'\n
\' unit on the item\')\n
quantity += item.getQuantity()\n
movement.setQuantity(quantity)\n
\n
return context.Base_redirect(form_id, keep_items=dict(\n
portal_status_message=translateString(\'Items created\')))\n
</string> </value>
]]></string> </value>
</item>
<item>
<key> <string>_code</string> </key>
......@@ -169,7 +190,6 @@ return context.Base_redirect(form_id, keep_items=dict(\n
<string>type</string>
<string>cell_portal_type</string>
<string>movement_cell_list</string>
<string>update_quantity</string>
<string>base_id</string>
<string>_getiter_</string>
<string>line</string>
......@@ -184,6 +204,12 @@ return context.Base_redirect(form_id, keep_items=dict(\n
<string>movement_to_update</string>
<string>variation_category_list</string>
<string>variation</string>
<string>update_quantity</string>
<string>movement_list</string>
<string>movement</string>
<string>quantity</string>
<string>len</string>
<string>_inplacevar_</string>
<string>dict</string>
</tuple>
</value>
......
......@@ -53,7 +53,9 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>from Products.ERP5Type.Message import translateString\n
<value> <string encoding="cdata"><![CDATA[
from Products.ERP5Type.Message import translateString\n
item_list = []\n
request = context.REQUEST\n
portal = context.getPortalObject()\n
......@@ -81,7 +83,6 @@ selection_tool.updateSelectionCheckedUidList(\n
list_selection_name, uids=uids, listbox_uid=listbox_uid, REQUEST=request)\n
uids = selection_tool.getSelectionCheckedUidsFor(list_selection_name)\n
\n
update_quantity = not context.Movement_isQuantityEditable()\n
\n
for item_uid in uids:\n
item = getObject(item_uid)\n
......@@ -109,26 +110,38 @@ for item_uid in uids:\n
*item_variation)\n
movement_to_update.edit(mapped_value_property_list=(\'quantity\', \'price\'),\n
variation_category_list=item_variation,)\n
\n
else:\n
# no variation, we\'ll update the line itself\n
movement_to_update = context\n
\n
if item not in movement_to_update.getAggregateValueList():\n
movement_to_update.setAggregateValueSet(\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
update_quantity = not context.Movement_isQuantityEditable()\n
if update_quantity:\n
if context.isMovement():\n
movement_list = context,\n
else:\n
movement_list = context.getCellValueList(base_id=\'movement\')\n
for movement in movement_list:\n
quantity = 0\n
item_list = movement.getAggregateValueList()\n
for item in item_list:\n
if item.getQuantityUnit() != movement.getQuantityUnit():\n
if len(item_list) > 1:\n
raise NotImplementedError(\n
\'Quantity unit from the movement differs from quantity\'\n
\' unit on the item\')\n
else:\n
movement.setQuantityUnit(item.getQuantityUnit())\n
quantity += item.getQuantity()\n
movement.setQuantity(quantity)\n
\n
return context.Base_redirect(form_id, keep_items=dict(\n
portal_status_message=translateString(\'Items aggregated\')))\n
</string> </value>
]]></string> </value>
</item>
<item>
<key> <string>_code</string> </key>
......@@ -183,7 +196,6 @@ return context.Base_redirect(form_id, keep_items=dict(\n
<string>line_portal_type</string>
<string>cell_portal_type</string>
<string>NotImplementedError</string>
<string>update_quantity</string>
<string>_getiter_</string>
<string>item_uid</string>
<string>item</string>
......@@ -195,6 +207,12 @@ return context.Base_redirect(form_id, keep_items=dict(\n
<string>_apply_</string>
<string>variation_category_list</string>
<string>variation</string>
<string>update_quantity</string>
<string>movement_list</string>
<string>movement</string>
<string>quantity</string>
<string>len</string>
<string>_inplacevar_</string>
<string>dict</string>
</tuple>
</value>
......
151
\ No newline at end of file
153
\ 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