Hi @airzoink ,
Did you added custom field on stock entry detail doctype? If yes then just goto Custom script > select doctype as stock entry > paste above script under Script field > save it.
On stock entry, select the price list first and then item code, one more thing you have to set the name of the field instead of fieldname in which you want to set the rate
@rohit_w
What i have done:
Added “Price List Rate” data field type in Stock Entry Detail
Added “Selling Price List” link field type in Stock Entry
Added your code as a Custom Script under Stock Entry DocType and changing the ‘fieldname’ to ‘selling_price_list’
I must be doing something not right since i don’t see the changes.
Fieldtype should be of type currency not data
use below code
frappe.ui.form.on("Stock Entry Detail", {
item_code: function(frm, cdt, cdn) {
child
me.frm.call({
method: "frappe.client.get_value",
args: {
doctype: "Item Price",
fieldname: "price_list_rate",
filters: { item_code: child.item_code, price_list : frm.doc.selling_price_list},
},
callback: function(r, rt) {
if(r.message) {
frappe.mode.set_value(cdt, cdn, 'price_list_rate', r.message.price_list_rate)
}
}
});
}
})
where,
fieldname is price_list_rate
price list is selling_price_list
Thanks
Made changes as you described. But price rate is still not displayed.
rohit_w
November 1, 2016, 9:31am
10
Hi @airzoink ,
share browser’s console log
rohit_w
November 1, 2016, 9:38am
12
Hi @airzoink
oops got the issue
frappe.ui.form.on("Stock Entry Detail", {
item_code: function(frm, cdt, cdn) {
child = locals[cdt][cdn];
me.frm.call({
method: "frappe.client.get_value",
args: {
doctype: "Item Price",
fieldname: "price_list_rate",
filters: { item_code: child.item_code, price_list : frm.doc.selling_price_list},
},
callback: function(r, rt) {
if(r.message) {
frappe.mode.set_value(cdt, cdn, 'price_list_rate', r.message.price_list_rate)
}
}
});
}
})
1 Like
rohit_w
November 1, 2016, 9:42am
14
Hi @airzoink
frappe.model.set_value(cdt, cdn, 'price_list_rate', r.message.price_list_rate)
@rohit_w
By the way can the script only show selling rates and not buying rate?
rohit_w
November 1, 2016, 11:43am
17
Hi @airzoink ,
It shows the rate of the selected price list, so don’t select the buying price list or use get_query for price list to show only selling price list.
@rohit_w
Can you give me an example on how to apply get_query?
Thanks!
@rohit_w
Based on the original script you have provided. Where do i insert these 7 lines of code?
If i edit it based on what i understand would it look like this?
frm.fields_dict.selling_price_list.get_query = function() {
return {
filters:{
‘selling’: ‘Yes’
}
}
}
Sorry i’m really a beginner at this. But i’m trying to understand bit by bit.
Hi @airzoink
Were you successful with this customization?
If the answer is yes: -Do you mind showing me how you achieved it?
Thanks in advance
@Muzzammil_Hussain
Can you please provide more details
you are missing this :
var child = locals[cdt][cdn];