JoEz
May 21, 2016, 8:57am
1
Hi all,
i’m quite new to ERPNext, how is possible to show Supplier Part Number in:
Report: Item Price
Item Price
I’ve seen something in Customize Form, but i’m not able to make it work .
Any help and example appreciated
Thanks a lot in advance!
JoEz
July 13, 2016, 10:42am
3
@saurabh6790 Hi there, got a solution for this using a custom-script:
frappe.ui.form.on("Item Price", {
onload: function (frm) {
if (frm.doc.buying) {
frappe.call({
"method": "frappe.client.get_value",
"args": {
"doctype": "Supplier",
"filters": {
default_price_list: ["=", frm.doc.price_list],
disabled: ["=", "0"],
},
"fieldname": ["name"]
},
callback: function (r) {
console.log(r.message.name);
frappe.call({
"method": "frappe.client.get_value",
"args": {
"doctype": "Item Supplier",
"filters": {
parent: ["=", frm.doc.item_code],
supplier: ["=", r.message.name],
},
"fieldname": ["supplier_part_no"]
},
callback: function (r) {
alert(r.message.supplier_part_no);
frm.set_value("supplier_part_no", r.message.supplier_part_no);
}
});
}
});
}
}
});
Is there a better solution?
Thx
Supplier Part No is supplier specific info. How it makes sense in Item Price document/report, because in Item Price we don’t define to which supplier the price list is applicable?
Okay, you are taking supplier based on default price list set on supplier. In that case, above script is does the job well. But may be you can write a function in the server side which will find the supplier and supplier part no in a single function and call that function from client side. That will save 1 ajax query.
JoEz
July 13, 2016, 10:58am
6
@nabinhait yeah u’re right …but i still not having that much experience in frappe and python. Can you suggest how to do that?
Thx in advance.
JoEz
July 13, 2016, 12:49pm
8
@nabinhait Thx for the hint …do u know how to customize without being effected from bench updates?
You have to create a new app for doing server side customizations.
Check Session 1: Creating an App - YouTube
JoEz
July 13, 2016, 12:59pm
10
@nabinhait Thx, i’ll have create an app to sync data with legacy system (kind of shopify app) and i think can be added this one also …
Yes, you can add the function in that app as well.