fix: serial / batch barcode scanner (#39114)
diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js
index 9427c38..4d8f683 100644
--- a/erpnext/public/js/controllers/transaction.js
+++ b/erpnext/public/js/controllers/transaction.js
@@ -454,7 +454,7 @@
item.weight_uom = '';
item.conversion_factor = 0;
- if(['Sales Invoice'].includes(this.frm.doc.doctype)) {
+ if(['Sales Invoice', 'Purchase Invoice'].includes(this.frm.doc.doctype)) {
update_stock = cint(me.frm.doc.update_stock);
show_batch_dialog = update_stock;
@@ -545,7 +545,7 @@
},
() => me.toggle_conversion_factor(item),
() => {
- if (show_batch_dialog)
+ if (show_batch_dialog && !frappe.flags.trigger_from_barcode_scanner)
return frappe.db.get_value("Item", item.item_code, ["has_batch_no", "has_serial_no"])
.then((r) => {
if (r.message &&
@@ -1239,6 +1239,20 @@
}
}
+ sync_bundle_data() {
+ let doctypes = ["Sales Invoice", "Purchase Invoice", "Delivery Note", "Purchase Receipt"];
+
+ if (this.frm.is_new() && doctypes.includes(this.frm.doc.doctype)) {
+ const barcode_scanner = new erpnext.utils.BarcodeScanner({frm:this.frm});
+ barcode_scanner.sync_bundle_data();
+ barcode_scanner.remove_item_from_localstorage();
+ }
+ }
+
+ before_save(doc) {
+ this.sync_bundle_data();
+ }
+
service_start_date(frm, cdt, cdn) {
var child = locals[cdt][cdn];
@@ -1576,6 +1590,18 @@
return item_list;
}
+ items_delete() {
+ this.update_localstorage_scanned_data();
+ }
+
+ update_localstorage_scanned_data() {
+ let doctypes = ["Sales Invoice", "Purchase Invoice", "Delivery Note", "Purchase Receipt"];
+ if (this.frm.is_new() && doctypes.includes(this.frm.doc.doctype)) {
+ const barcode_scanner = new erpnext.utils.BarcodeScanner({frm:this.frm});
+ barcode_scanner.update_localstorage_scanned_data();
+ }
+ }
+
_set_values_for_item_list(children) {
const items_rule_dict = {};