msiam
1
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;
});
});
NCP
2
Hi @msiam,
In your custom app, please add in hook.
# my_app/hooks.py
doc_events = {
"Painter Sales": {
"onload": "my_app.utils.set_point_amount"
}
}
# my_app/utils.py
# 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},
fieldname="point_amount")
if point_amount:
item.point_amount = point_amount
Thank You!