fix: Update Items on Purchase Order

1. set warehouse using `get_item_warehouse`
2. update "reserved_qty" for sales order
This commit is contained in:
Andy Zhu 2020-10-06 10:51:42 +13:00 committed by marination
parent a21e347bf1
commit c0ba6eafd5

View File

@ -1321,7 +1321,7 @@ def set_order_defaults(parent_doctype, parent_doctype_name, child_doctype, child
date_fieldname = "delivery_date" if child_doctype == "Sales Order Item" else "schedule_date" date_fieldname = "delivery_date" if child_doctype == "Sales Order Item" else "schedule_date"
child_item.update({date_fieldname: trans_item.get(date_fieldname) or p_doc.get(date_fieldname)}) child_item.update({date_fieldname: trans_item.get(date_fieldname) or p_doc.get(date_fieldname)})
child_item.uom = trans_item.get("uom") or item.stock_uom 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")) 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.conversion_factor = flt(trans_item.get('conversion_factor')) or conversion_factor
if child_doctype == "Purchase Order Item": if child_doctype == "Purchase Order Item":
@ -1361,9 +1361,9 @@ def validate_and_delete_children(parent, data):
d.cancel() d.cancel()
d.delete() d.delete()
from erpnext.stock.stock_balance import update_bin_qty, get_ordered_qty from erpnext.stock.stock_balance import update_bin_qty, get_reserved_qty, get_ordered_qty
frappe.errprint(f"Item Code: {d.item_code}, Warehouse: {d.warehouse}")
update_bin_qty(d.item_code, d.warehouse, { 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) "ordered_qty": get_ordered_qty(d.item_code, d.warehouse)
}) })