mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-01 03:09:09 +00:00
fix: handle for product bundle (#18421)
This commit is contained in:
committed by
Nabin Hait
parent
8a5bd02662
commit
7620742299
@@ -115,6 +115,11 @@ def get_data():
|
|||||||
{"sales_order_item": ("!=",""), "docstatus": 1},
|
{"sales_order_item": ("!=",""), "docstatus": 1},
|
||||||
["parent", "qty", "sales_order", "item_code"])
|
["parent", "qty", "sales_order", "item_code"])
|
||||||
|
|
||||||
|
packed_items = get_packed_items([row.name for row in sales_order_entry])
|
||||||
|
|
||||||
|
item_with_product_bundle = get_item_with_product_bundle([row.item_code for row in sales_order_entry])
|
||||||
|
item_with_product_bundle = [row.new_item_code for row in item_with_product_bundle]
|
||||||
|
|
||||||
materials_request_dict = {}
|
materials_request_dict = {}
|
||||||
|
|
||||||
for record in mr_records:
|
for record in mr_records:
|
||||||
@@ -139,19 +144,57 @@ def get_data():
|
|||||||
|
|
||||||
# check for pending sales order
|
# check for pending sales order
|
||||||
if cint(so.net_qty) > cint(materials_request.get('qty')):
|
if cint(so.net_qty) > cint(materials_request.get('qty')):
|
||||||
so_record = {
|
|
||||||
"item_code": so.item_code,
|
if so.item_code not in item_with_product_bundle:
|
||||||
"item_name": so.item_name,
|
so_record = {
|
||||||
"description": so.description,
|
"item_code": so.item_code,
|
||||||
"sales_order_no": so.name,
|
"item_name": so.item_name,
|
||||||
"date": so.transaction_date,
|
"description": so.description,
|
||||||
"material_request": ','.join(materials_request.get('material_requests', [])),
|
"sales_order_no": so.name,
|
||||||
"customer": so.customer,
|
"date": so.transaction_date,
|
||||||
"territory": so.territory,
|
"material_request": ','.join(materials_request.get('material_requests', [])),
|
||||||
"so_qty": so.net_qty,
|
"customer": so.customer,
|
||||||
"requested_qty": cint(materials_request.get('qty')),
|
"territory": so.territory,
|
||||||
"pending_qty": so.net_qty - cint(materials_request.get('qty')),
|
"so_qty": so.net_qty,
|
||||||
"company": so.company
|
"requested_qty": cint(materials_request.get('qty')),
|
||||||
}
|
"pending_qty": so.net_qty - cint(materials_request.get('qty')),
|
||||||
pending_so.append(so_record)
|
"company": so.company
|
||||||
return pending_so
|
}
|
||||||
|
pending_so.append(so_record)
|
||||||
|
else:
|
||||||
|
for item in packed_items:
|
||||||
|
material_request_qty = materials_request.get('qty') if materials_request.get('qty') else 0
|
||||||
|
so_record = {
|
||||||
|
"item_code": item.item_code,
|
||||||
|
"item_name": item.item_name,
|
||||||
|
"description": item.description,
|
||||||
|
"sales_order_no": so.name,
|
||||||
|
"date": so.transaction_date,
|
||||||
|
"material_request": ','.join(materials_request.get('material_requests', [])),
|
||||||
|
"customer": so.customer,
|
||||||
|
"territory": so.territory,
|
||||||
|
"so_qty": item.qty,
|
||||||
|
"requested_qty": cint(material_request_qty * item.qty),
|
||||||
|
"pending_qty": (so.net_qty - cint(material_request_qty)) * item.qty,
|
||||||
|
"company": so.company
|
||||||
|
}
|
||||||
|
pending_so.append(so_record)
|
||||||
|
|
||||||
|
|
||||||
|
return pending_so
|
||||||
|
|
||||||
|
def get_item_with_product_bundle(item_list):
|
||||||
|
|
||||||
|
bundled_item = frappe.get_all("Product Bundle", filters = [
|
||||||
|
("new_item_code", "IN", item_list)
|
||||||
|
], fields = ["new_item_code"])
|
||||||
|
|
||||||
|
return bundled_item
|
||||||
|
|
||||||
|
def get_packed_items(sales_order_list):
|
||||||
|
|
||||||
|
packed_items = frappe.get_all("Packed Item", filters = [
|
||||||
|
("parent", "IN", sales_order_list)
|
||||||
|
], fields = ["*"])
|
||||||
|
|
||||||
|
return packed_items
|
||||||
|
|||||||
Reference in New Issue
Block a user