diff --git a/bt5/erp5_item/SkinTemplateItem/portal_skins/erp5_item/DeliveryLine_createItemList.xml b/bt5/erp5_item/SkinTemplateItem/portal_skins/erp5_item/DeliveryLine_createItemList.xml index 1076a3fb0ffeadbcac3240f18c67b94c2fbc89dd..2937042b8202a5622cfaef29342faa9535a4c616 100644 --- a/bt5/erp5_item/SkinTemplateItem/portal_skins/erp5_item/DeliveryLine_createItemList.xml +++ b/bt5/erp5_item/SkinTemplateItem/portal_skins/erp5_item/DeliveryLine_createItemList.xml @@ -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> diff --git a/bt5/erp5_item/SkinTemplateItem/portal_skins/erp5_item/DeliveryLine_selectItemList.xml b/bt5/erp5_item/SkinTemplateItem/portal_skins/erp5_item/DeliveryLine_selectItemList.xml index e68de86d4fe72e9ebbd59c5563218c1c9c1de7cf..1497ae8368f00eade478413b8d76361127a74976 100644 --- a/bt5/erp5_item/SkinTemplateItem/portal_skins/erp5_item/DeliveryLine_selectItemList.xml +++ b/bt5/erp5_item/SkinTemplateItem/portal_skins/erp5_item/DeliveryLine_selectItemList.xml @@ -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> diff --git a/bt5/erp5_item/bt/revision b/bt5/erp5_item/bt/revision index c663e4d093b2a397637e836bfae88ca26365cc33..f79f5e337ea18102bf116113d489fb73bd210e37 100644 --- a/bt5/erp5_item/bt/revision +++ b/bt5/erp5_item/bt/revision @@ -1 +1 @@ -151 \ No newline at end of file +153 \ No newline at end of file