From ceffbf243e4d39258874c290fa7400577dca7dd1 Mon Sep 17 00:00:00 2001 From: Devin Slauenwhite Date: Wed, 27 Apr 2022 22:07:25 -0400 Subject: [PATCH] fix: show alert when maximum qty scanned is reached --- erpnext/public/js/utils/barcode_scanner.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/erpnext/public/js/utils/barcode_scanner.js b/erpnext/public/js/utils/barcode_scanner.js index b162697e324..24d49a45fb7 100644 --- a/erpnext/public/js/utils/barcode_scanner.js +++ b/erpnext/public/js/utils/barcode_scanner.js @@ -11,6 +11,10 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner { this.batch_no_field = opts.batch_no_field || "batch_no"; this.qty_field = opts.qty_field || "qty"; this.max_qty_field = opts.max_qty_field || null; + this.allow_new_row = opts.allow_new_row; + if (this.allow_new_row === undefined || this.allow_new_row === null) { + this.allow_new_row = true; + } this.items_table_name = opts.items_table_name || "items"; this.items_table = this.frm.doc[this.items_table_name]; @@ -73,6 +77,15 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner { } if (!row) { + if (!this.allow_new_row) { + frappe.show_alert({ + message: __("Maximum quantity scanned for this barcode."), + indicator: "red" + }); + this.clean_up(); + return; + } + // add new row if new item/batch is scanned row = frappe.model.add_child(this.frm.doc, cur_grid.doctype, this.items_table_name); // trigger any row add triggers defined on child table.