fix: Update Items on Purchase Order
1. set warehouse using `get_item_warehouse`
2. update "reserved_qty" for sales order
diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py
index a53b355..a2b2da0 100644
--- a/erpnext/controllers/accounts_controller.py
+++ b/erpnext/controllers/accounts_controller.py
@@ -1204,7 +1204,7 @@
child_item.description = item.description
child_item.schedule_date = trans_item.get('schedule_date') or p_doc.schedule_date
child_item.uom = trans_item.get("uom") or item.stock_uom
- child_item.warehouse = p_doc.set_warehouse
+ child_item.warehouse = get_item_warehouse(item, p_doc, overwrite_warehouse=True)
conversion_factor = flt(get_conversion_factor(item.item_code, child_item.uom).get("conversion_factor"))
child_item.conversion_factor = flt(trans_item.get('conversion_factor')) or conversion_factor
child_item.base_rate = 1 # Initiallize value will update in parent validation
@@ -1237,9 +1237,9 @@
d.cancel()
d.delete()
- from erpnext.stock.stock_balance import update_bin_qty, get_ordered_qty
- frappe.errprint(f"Item Code: {d.item_code}, Warehouse: {d.warehouse}")
+ from erpnext.stock.stock_balance import update_bin_qty, get_reserved_qty, get_ordered_qty
update_bin_qty(d.item_code, d.warehouse, {
+ "reserved_qty": get_reserved_qty(d.item_code, d.warehouse),
"ordered_qty": get_ordered_qty(d.item_code, d.warehouse)
})