Supplier Part Number in Item Price

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 :cry:.

Any help and example appreciated

Thanks a lot in advance!

@JoEz https://frappe.github.io/erpnext/user/manual/en/customize-erpnext/customize-form.html

@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.

@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.

Please look into similar existing functionality and how frappe.call works. For example, https://github.com/frappe/erpnext/blob/develop/erpnext/hr/doctype/leave_application/leave_application.js#L72

@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

@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.