fix: Packing Slip Item Qty

(cherry picked from commit 372bce4567)
This commit is contained in:
s-aga-r
2023-04-28 15:24:23 +05:30
committed by Mergify
parent 19713f9f6f
commit 5345ebe242

View File

@@ -684,6 +684,9 @@ def make_packing_slip(source_name, target_doc=None):
def set_missing_values(source, target): def set_missing_values(source, target):
target.run_method("set_missing_values") target.run_method("set_missing_values")
def update_item(obj, target, source_parent):
target.qty = flt(obj.qty) - flt(obj.packed_qty)
doclist = get_mapped_doc( doclist = get_mapped_doc(
"Delivery Note", "Delivery Note",
source_name, source_name,
@@ -704,8 +707,10 @@ def make_packing_slip(source_name, target_doc=None):
"stock_uom": "stock_uom", "stock_uom": "stock_uom",
"name": "dn_detail", "name": "dn_detail",
}, },
"condition": lambda doc: not frappe.db.exists( "postprocess": update_item,
"Product Bundle", {"new_item_code": doc.item_code} "condition": lambda doc: (
not frappe.db.exists("Product Bundle", {"new_item_code": doc.item_code})
and (doc.qty - doc.packed_qty) > 0
), ),
}, },
"Packed Item": { "Packed Item": {
@@ -718,6 +723,8 @@ def make_packing_slip(source_name, target_doc=None):
"qty": "qty", "qty": "qty",
"name": "pi_detail", "name": "pi_detail",
}, },
"postprocess": update_item,
"condition": lambda doc: ((doc.qty - doc.packed_qty) > 0),
}, },
}, },
target_doc, target_doc,