fix: Update Items on Purchase Order

If user add rows or remove rows to update items on purchase order, the quantity in bin won't get updated.
This fix is not mature yet but to give an tempopary solution for fixing this issue.
This commit is contained in:
Andy Zhu 2020-10-05 12:16:48 +13:00 committed by GitHub
parent 2016a34e30
commit 760248911d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1204,6 +1204,7 @@ def set_purchase_order_defaults(parent_doctype, parent_doctype_name, child_docna
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
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
@ -1235,6 +1236,12 @@ def validate_and_delete_children(parent, data):
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}")
update_bin_qty(d.item_code, d.warehouse, {
"ordered_qty": get_ordered_qty(d.item_code, d.warehouse)
})
@frappe.whitelist()
def update_child_qty_rate(parent_doctype, trans_items, parent_doctype_name, child_docname="items"):