I want to make custom in purchase order, i want to make the uom that can be selected in purchase order is uom that refers to uoms in item. is anyone can help? thanks a lot
so, the condition right now, for example i have item named “A” and the uoms is pcs and box, then if i make an purchase order, when i select item “A”, the uom can be change to nos, i want to make it when i choose item “A”, the only uom that i can choose is whether pcs or box, nothing else. can u help?
Hello
frappe.ui.form.on("Purchase Order", {
setup: function (frm) {
frm.set_query("uom", "items", function (doc, cdt, cdn) {
let row = locals[cdt][cdn];
return {
query:
"erpnext.accounts.doctype.pricing_rule.pricing_rule.get_item_uoms",
filters: {
value: row.item_code,
apply_on: "Item Code",
},
};
});
},
});
Apply above code by client script
Then only item uoms will be visible in the drop down
frappe.ui.form.on('Purchase Order', {
refresh:function(frm,cdt,cdn){
frm.fields_dict.items.grid.get_field('uom').get_query = function(doc, cdt, cdn) {
var row = locals[cdt][cdn];
if (row.item_code) {
return {
query: "your_function_path.fetch_uom_query",
filters: { "item": row.item_code }
};
}
};
},
and py file code
@frappe.whitelist()
def fetch_uom_query(doctype, txt, searchfield, start, page_len, filters):
item_uom = frappe.db.get_all("UOM Conversion Detail", {'parent': filters['item']}, 'uom')
return item_uom
1 Like