Skip to content

Commit

Permalink
fix: barcode field on line item not working (#40381)
Browse files Browse the repository at this point in the history
  • Loading branch information
rohitwaghchaure authored Mar 12, 2024
1 parent b9a8dd4 commit 0da19a4
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
12 changes: 12 additions & 0 deletions erpnext/public/js/controllers/stock_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@ erpnext.stock.StockController = class StockController extends frappe.ui.form.Con
}
}

barcode(doc, cdt, cdn) {
let row = locals[cdt][cdn];
if (row.barcode) {
erpnext.stock.utils.set_item_details_using_barcode(this.frm, row, (r) => {
frappe.model.set_value(cdt, cdn, {
"item_code": r.message.item_code,
"qty": 1,
});
});
}
}

setup_warehouse_query() {
var me = this;
erpnext.queries.setup_queries(this.frm, "Warehouse", function() {
Expand Down
13 changes: 13 additions & 0 deletions erpnext/public/js/controllers/transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,19 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
barcode_scanner.process_scan();
}

barcode(doc, cdt, cdn) {
let row = locals[cdt][cdn];
if (row.barcode) {
erpnext.stock.utils.set_item_details_using_barcode(this.frm, row, (r) => {
debugger
frappe.model.set_value(cdt, cdn, {
"item_code": r.message.item_code,
"qty": 1,
});
});
}
}

validate_has_items () {
let table = this.frm.doc.items;
this.frm.has_items = (table && table.length
Expand Down
8 changes: 8 additions & 0 deletions erpnext/public/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// License: GNU General Public License v3. See license.txt
frappe.provide("erpnext");
frappe.provide("erpnext.utils");
frappe.provide("erpnext.stock.utils");

$.extend(erpnext, {
get_currency: function (company) {
Expand Down Expand Up @@ -1201,3 +1202,10 @@ function attach_selector_button(inner_text, append_loction, context, grid_row) {
context.show_serial_batch_selector(grid_row.frm, grid_row.doc, "", "", true);
});
}

$.extend(erpnext.stock.utils, {
set_item_details_using_barcode(frm, child_row, callback) {
const barcode_scanner = new erpnext.utils.BarcodeScanner({ frm: frm });
barcode_scanner.scan_api_call(child_row.barcode, callback);
},
});

0 comments on commit 0da19a4

Please sign in to comment.