diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index 844db996a29..a9b19eddd7e 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -277,8 +277,30 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ this.set_dynamic_labels(); this.setup_sms(); this.setup_quality_inspection(); - this.frm.fields_dict["scan_barcode"] && this.frm.fields_dict["scan_barcode"].set_value(""); - this.frm.fields_dict["scan_barcode"] && this.frm.fields_dict["scan_barcode"].set_new_description(""); + let scan_barcode_field = this.frm.get_field('scan_barcode'); + if (scan_barcode_field) { + scan_barcode_field.set_value(""); + scan_barcode_field.set_new_description(""); + + if (frappe.is_mobile()) { + if (scan_barcode_field.$input_wrapper.find('.input-group').length) return; + + let $input_group = $('
'); + scan_barcode_field.$input_wrapper.find('.control-input').append($input_group); + $input_group.append(scan_barcode_field.$input); + $(` + + `) + .on('click', '.btn', () => { + frappe.barcode.scan_barcode().then(barcode => { + scan_barcode_field.set_value(barcode); + }); + }) + .appendTo($input_group); + } + } }, scan_barcode: function() {