- I’ve Invoice like Doctype with Child Table for Items.
- I’m currently getting it mapped from sales order where the item table is copied. drop_ship_invoice.py
- I’ve added purchase_rate currency field in the child table with item.
- And I’ve added price_list Link field in parent Doctype.
Is there a way to get item rate from price list?
Currently my hack is in doctype’s js file
drop_ship_invoice.js:
var items = doc.items || [];
for(var i=0;i<items.length;i++) {
frappe.call({
method: "frappe.client.get",
args: {
doctype: "Item Price",
filters: {
"price_list": doc.price_list,
"item_code": items[i].item_code
}
},
callback: function (data) {
pr = data.message.price_list_rate;
}
});
items[i].purchase_rate = flt(pr);
refresh_field('purchase_rate', doc.items);
items[i].amount = flt(flt(items[i].rate) * flt(items[i].qty));
doc.total += items[i].amount;
items[i].purchase_amount = flt(flt(items[i].purchase_rate) * flt(items[i].qty));
doc.purchase_total += items[i].purchase_amount;
}
This is not getting item price from price list as expected.