Fill items in sales order using Customer Ref code

Hi there

I need help in creating a custom script, which would allow me to enter sales order item using customer ref_code, instead of item_code, it gives us speed in entering sales orders.

any help would be appreciated.

It would be easy if we can use the “search_field” in the item master. But since it is a child table in item master we can’t use that feature.

What I would suggest is:

  • Add a data field just abode the grid (customer_ref_search)
  • Add a custom script for that field
  • When user enter data to that field search it in the customer info table
  • If it founds an item, add it in the grid (Barcode fields increments the qty if it is already in the grid)

Your script should look like:

frappe.ui.form.on("Sales Order", {
customer_ref_search : function(frm, cdt, cdn) {
    if (frm.doc.customer_ref_search) {
         let item_info = frappe.db.get_list("ITEM CUSTOMER TABLE", ...

var rowSOItem = frappe.model.add_child(frm.doc, 'Sales Order Item', 'items');
frappe.model.set_value(rowSOItem.doctype,, 'item_code', item_info.item_code);

PS: I hope you get the idea.