Hi,
I’m using the following custom script to add a row to our table if the ordered amount makes the stock of an item go below 0. (We use a different item for items that need be delivered after a certain event)
frappe.ui.form.on("Sales Order Item", "qty", function(frm, doctype, name) {
var row = locals[doctype][name];
frappe.model.set_value(doctype, name, "projected_stock", row.actual_qty - row.qty);
if(row.projected_stock < 0){
var new_row_qty = (row.projected_stock*-1);
row.qty = row.actual_qty;
refresh_field(row.qty);
refresh_field(row.projected_stock);
var new_row = cur_frm.add_child("items");
new_row.item_code = row.item_code + " (order)";
new_row.qty = new_row_qty;
new_row.stock_uom = row.stock_uom;
new_row.rate = row.rate;
new_row.item_name = row.item_name;
new_row.amount = new_row.qty * new_row.rate;
new_row.supplier = row.supplier;
}
});
While I see the new row added with the correct information in the items table, the screen remains grayed out (as if the popup were still there), and there is no way to interact with any buttons or fields. What am I missing here?
Thomas