Convert fetching JS fetch to Python method

Dear All

i want to convert this JS fetching to python method(@frappe.whitelist()) and recall it onload from hooks

set point amount without change any field in child table

frappe.ui.form.on(“Painter Sales Item”, “qr_code”, function(frm, cdt, cdn) {
var d = locals[cdt][cdn];
frappe.db.get_value(“Master Painter Item Category Matrix”, {“item_number”: d.item_number}, “point_amount”, function(value) {
d.point_amount = value.point_amount;

Hi @msiam,

In your custom app, please add in hook.

# my_app/

doc_events = {
    "Painter Sales": {
        "onload": "my_app.utils.set_point_amount"
# my_app/
# set your path according
import frappe

def set_point_amount(doc, method):
    for item in doc.items:
        point_amount = frappe.db.get_value("Master Painter Item Category Matrix",
                                           filters={"item_number": item.item_number},
        if point_amount:
            item.point_amount = point_amount

Thank You!