Is there a custom script i can use to display price list rate per item in Stock Entry? Thanks!
Hi @airzoink,
Add custom field price list on the stock entry details table and use below script
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 : child.price_list},
},
callback: function(r, rt) {
if(r.message) {
frappe.mode.set_value(cdt, cdn, 'fieldname', r.message.price_list_rate)
}
}
});
}
})
@rohit_w Thanks! Will i be able to specify which price list to use? Similar to Quotation and Sales Order?
Hi @airzoink ! You can create custom field link to your pricelist doctype. Then integrate it with your script to just pick up prices there.
@creamdory I tried making Price List link but i do not know how to integrate it with the script above. Can you help me with this?
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
Browserās Console Log
VM1511:509 Uncaught ReferenceError: child is not defined(ā¦)item_code @ VM1511:509(anonymous function) @ form.min.js:254(anonymous function) @ form.min.js:254map @ jquery.min.js:2trigger @ form.min.js:254(anonymous function) @ form.min.js:33(anonymous function) @ desk.min.js:548each @ jquery.min.js:2run @ desk.min.js:548trigger @ desk.min.js:548set_value @ desk.min.js:547set_model_value @ desk.min.js:384set @ desk.min.js:383callback @ form.min.js:261callback @ desk.min.js:133200 @ desk.min.js:135(anonymous function) @ desk.min.js:140i @ jquery.min.js:2fireWith @ jquery.min.js:2z @ jquery.min.js:4(anonymous function) @ jquery.min.js:4
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)
}
}
});
}
})
Applied. New error
VM2241:519 Uncaught TypeError: Cannot read property āset_valueā of undefined(ā¦)callback @ VM2241:519opts.callback @ form.min.js:176callback @ desk.min.js:133200 @ desk.min.js:135(anonymous function) @ desk.min.js:140i @ jquery.min.js:2fireWith @ jquery.min.js:2z @ jquery.min.js:4(anonymous function) @ jquery.min.js:4
Success!
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.
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.