Merge pull request #2503 from nabinhait/fix1

packing list index
This commit is contained in:
Nabin Hait 2014-12-16 15:17:27 +05:30
commit f638c1acd5

View File

@ -27,7 +27,7 @@ def get_bin_qty(item, warehouse):
where item_code = %s and warehouse = %s""", (item, warehouse), as_dict = 1)
return det and det[0] or ''
def update_packing_list_item(obj, packing_item_code, qty, warehouse, line, packing_list_idx):
def update_packing_list_item(obj, packing_item_code, qty, warehouse, line):
bin = get_bin_qty(packing_item_code, warehouse)
item = get_packing_item_details(packing_item_code)
@ -54,9 +54,7 @@ def update_packing_list_item(obj, packing_item_code, qty, warehouse, line, packi
pi.warehouse = warehouse
if not pi.batch_no:
pi.batch_no = cstr(line.get("batch_no"))
pi.idx = packing_list_idx
packing_list_idx += 1
def make_packing_list(obj, item_table_fieldname):
@ -64,13 +62,11 @@ def make_packing_list(obj, item_table_fieldname):
if obj.get("_action") and obj._action == "update_after_submit": return
packing_list_idx = 0
parent_items = []
for d in obj.get(item_table_fieldname):
if frappe.db.get_value("Sales BOM", {"new_item_code": d.item_code}):
for i in get_sales_bom_items(d.item_code):
update_packing_list_item(obj, i['item_code'], flt(i['qty'])*flt(d.qty),
d.warehouse, d, packing_list_idx)
update_packing_list_item(obj, i['item_code'], flt(i['qty'])*flt(d.qty), d.warehouse, d)
if [d.item_code, d.name] not in parent_items:
parent_items.append([d.item_code, d.name])