From 5345ebe2426d518f8de7d9463fec47fc020bace2 Mon Sep 17 00:00:00 2001 From: s-aga-r Date: Fri, 28 Apr 2023 15:24:23 +0530 Subject: [PATCH] fix: Packing Slip Item Qty (cherry picked from commit 372bce45675ac0232219097cc191bc662962a49f) --- erpnext/stock/doctype/delivery_note/delivery_note.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.py b/erpnext/stock/doctype/delivery_note/delivery_note.py index 9449f6e81785..6fbc8870eefe 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.py +++ b/erpnext/stock/doctype/delivery_note/delivery_note.py @@ -684,6 +684,9 @@ def make_packing_slip(source_name, target_doc=None): def set_missing_values(source, target): 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( "Delivery Note", source_name, @@ -704,8 +707,10 @@ def set_missing_values(source, target): "stock_uom": "stock_uom", "name": "dn_detail", }, - "condition": lambda doc: not frappe.db.exists( - "Product Bundle", {"new_item_code": doc.item_code} + "postprocess": update_item, + "condition": lambda doc: ( + not frappe.db.exists("Product Bundle", {"new_item_code": doc.item_code}) + and (doc.qty - doc.packed_qty) > 0 ), }, "Packed Item": { @@ -718,6 +723,8 @@ def set_missing_values(source, target): "qty": "qty", "name": "pi_detail", }, + "postprocess": update_item, + "condition": lambda doc: ((doc.qty - doc.packed_qty) > 0), }, }, target_doc,