Get Item Rate from Price List

  1. I’ve Invoice like Doctype with Child Table for Items.
  2. I’m currently getting it mapped from sales order where the item table is copied. drop_ship_invoice.py
  3. I’ve added purchase_rate currency field in the child table with item.
  4. 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.

Its a bit complicated…:

@revant_one were you able to resolve this via custom script? I’m trying to do same but no luck…

no solution yet. I can think of server side get_value/sql and custom script. I haven’t tried it.