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 4e70d220cb2bdfc131cd9eb2e6db2f0ef6a6b067..3db50517918881d8a12a3992d7f0717a34414090 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 @@ -68,7 +68,7 @@ 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 -context.setVariationCategoryList([])\n +update_quantity = not context.Movement_isQuantityEditable()\n base_id = \'movement\'\n for line in kw.get(\'listbox\'):\n if line.has_key(\'listbox_key\') and line[\'quantity\'] in (\'\',None):\n @@ -89,30 +89,44 @@ for line in kw.get(\'listbox\'):\n \n \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 - context.setVariationCategoryList(context.getVariationCategoryList()+new_list)\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 - quantity = line[\'quantity\']\n - cell = context.newCell(base_id=base_id, \\\n - portal_type=cell_portal_type,*cell_key)\n - cell.edit(mapped_value_property_list=[\'price\',\'quantity\'],\n - price=cell.getPrice(), quantity=cell.getQuantity()+quantity,\n - predicate_category_list=cell_key,\n - variation_category_list=cell_key)\n - cell.setAggregateValueList(cell.getAggregateValueList()+[item])\n - total_quantity+=line[\'quantity\']\n -\n -if movement_cell_list ==[]:\n - context.setQuantity(context.getQuantity()+total_quantity)\n -else:\n - context.setQuantity(total_quantity)\n + cell_found = None\n + for cell in context.getCellValueList(base_id=\'movement\'):\n + if cell.getVariationCategoryList() == line["variation_category_list"]:\n + cell_found = cell\n + break\n + if cell_found is not None:\n + movement_to_update = cell_found\n + else:\n + if not context.hasInRange(base_id=\'movement\', *line["variation_category_list"]):\n + # update line variation category list, if not already containing this one\n + variation_category_list = context.getVariationCategoryList()\n + for variation in line["variation_category_list"]:\n + if variation not in variation_category_list:\n + variation_category_list.append(variation)\n + context.setVariationCategoryList(variation_category_list)\n + movement_to_update = context.newCell(base_id=\'movement\',\n + portal_type=cell_portal_type,\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 -if context.getVariationCategoryList()==[]: \n - context.setAggregateValueList(item_list )\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 + 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 return context.Base_redirect(form_id, keep_items=dict(\n - portal_status_message=translateString(\'Items created\')))\n + portal_status_message=translateString(\'Items created\')))\n </string> </value> </item> <item> @@ -162,6 +176,7 @@ 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> @@ -171,14 +186,13 @@ return context.Base_redirect(form_id, keep_items=dict(\n <string>dict</string> <string>module</string> <string>item</string> - <string>filter</string> - <string>new_list</string> - <string>list</string> - <string>cell_key</string> - <string>quantity</string> - <string>_apply_</string> + <string>cell_found</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> </value> </item> diff --git a/bt5/erp5_item/bt/revision b/bt5/erp5_item/bt/revision index b5db9c417a229cf02976899b74f8b6fc87712919..c2807f7f3cebe94f4ce652ca42b80dcc5853fe2d 100644 --- a/bt5/erp5_item/bt/revision +++ b/bt5/erp5_item/bt/revision @@ -1 +1 @@ -139 \ No newline at end of file +140 \ No newline at end of file diff --git a/bt5/erp5_item/bt/template_action_path_list b/bt5/erp5_item/bt/template_action_path_list index 69ed892ec33f2119559c1aff933b89903ce5c629..a67c8a739ce9cd7c881e4bd3cc98abc757d00904 100644 --- a/bt5/erp5_item/bt/template_action_path_list +++ b/bt5/erp5_item/bt/template_action_path_list @@ -1,4 +1,5 @@ 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 | aggregate_item Item Module | create_order