ERPNext Built in QR Scanner Performs Poorly

Hi,

I have a client script that opens the built in html 5 qr scanner in the browser to let the user scan a QR Code. The issue is that I can only scan very large QR codes, the smaller ones get ignored. The QR codes I’m using works absolutely perfect on my Samsung 21’s native QR scanner and I think the issue has to do with auto-focusing. Is there a way to tweak some settings of the QR scanner in the client script or maybe open the phones native QR Scanner app?

Complete script:

frappe.listview_settings['QR Code'] = {

    //Add scan QR button and route to scanned qr code
    onload: function(listview) {
        
        // triggers once before the list is loaded
        listview.page.set_secondary_action('Scan', () => {
            console.log("Scan QR Pressed");
            new frappe.ui.Scanner({
              dialog: true, // open camera scanner in a dialog
              multiple: false, // stop after scanning one value
              on_scan(data) {
      			/*frappe.msgprint({
                    title: __('Notification'),
                    indicator: 'green',
                    message: __(data.decodedText)
                });*/
                
                var qr_code_document;
                frappe.call({
                    method: 'frappe.client.get_list',
                    args: {
                        doctype: 'QR Code',
                        filters: [
                            ['serialnumber', '=', data.decodedText]
                        ]
                    },
                    callback: e => {
                        //if the qr codee exists
                        if (e.message.length !== 0){
                        //console.log(e.message);
                            console.log(e.message[0].name);
                            qr_code_document = e.message[0].name;
                            frappe.set_route("Form", "QR Code", qr_code_document);
                        }
                        //notify user if the qr code does not exist
                        else{
                            frappe.msgprint({
                                title: __('Error'),
                                indicator: 'red',
                                message: __("QR Code does not exist!")
                            });
                        }

                    }
                });
 
                }
            });
        });
  }
    
};
1 Like