Good Afternoon,
Can i have my sales Invoice show my available qty when item is scanned on the sales invoice.
How can i achieve this?
Good Afternoon,
Can i have my sales Invoice show my available qty when item is scanned on the sales invoice.
How can i achieve this?
Hey @kolotayo, to do so, please…
Place a custom field to display the data in the Sales Invoice Item
Form.
Sales Invoice Item
qty_in_stock
(it could be any name) and we recomend to make it the read onlyAfter you finish that out you can create a new Custom Script for the doctype Sales Invoice
and copy and paste the following code:
frappe.ui.form.on("Sales Invoice Item", "item_code", function(frm, cdt, cdn) {
var row = frappe.get_doc(cdt, cdn);
frappe.call({
"method": "frappe.client.get_value",
"args": {
"doctype": "Stock Ledger Entry",
"filters": {
"item_code": row.item_code,
"warehouse": row.warehouse
},
"fieldname": ["sum(actual_qty) qty"],
},
"callback": function(response) {
var r = response.message;
if (r && r.qty) {
frappe.model.set_value(cdt, cdn, "qty_in_stock", r.qty);
}
}
})
})
Thank You this works perfectly
But the issue i have about it now is that The Filed is showing and available but the Stock Qty is not showing anything.
Any help please?