Once I select an Item in an Sales invoice, I want to display the Purchase price of the Item in one of the field (custom_purchase_price ) in the Sales Invoice Item Child Table in Sales Invoice.
(The Purchase Price shall be fetched from the Item Price Doctype, field : price_list_rate).
Below is Client Script:
frappe.ui.form.on(“Sales Invoice Item”, “item_code”, function(frm, cdt, cdn) {
var d = locals[cdt][cdn];
frappe.db.get_value(“Item Price”, {“name”: d.item_code}, “price_list_rate”, function(value) {
d.custom_purchase_price = value.price_list_rate;
});
});