Is Erpnext support QR code at inventory module
ok from what I understand is this needs to be added as an app?
Hi
I found a video on how this was done for bar-codes Prateeksha Singh - Frappe Controls, Barcode Controller - YouTube
Looking at this bar-codes, qr-codes can be done in the same way.
the controller
import Jsqrcode from āqrcodejsā;
frappe.ui.form.Controlqrcode = frappe.ui.form.ControlData.extend({
make_wrapper() {
// Create the elements for qrcode area
this._super();
let $input_wrapper = this.$wrapper.find('.control-input-wrapper');
this.qrcode_area = $(`<div class="qrcode-wrapper border"><svg height=80></svg></div>`);
this.qrcode_area.appendTo($input_wrapper);
},
parse(value) {
// Parse raw value
return value ? this.get_qrcode_html(value) : "";
},
set_formatted_input(value) {
// Set values to display
const svg = value;
const qrcode_value = $(svg).attr('data-qrcode-value');
this.$input.val(qrcode_value);
this.qrcode_area.html(svg);
},
get_qrcode_html(value) {
// Get svg
const svg = this.qrcode_area.find('svg')[0];
Jsqrcode(svg, value, this.get_options(value));
$(svg).attr('data-qrcode-value', value);
return this.qrcode_area.html();
},
get_options(value) {
// get Jsqrcode options
let options = JSON.parse('{ "height" : 40 }');
if (this.isValidJson(this.df.options)) {
options = JSON.parse(this.df.options);
if (options.format && options.format === "EAN") {
options.format = value.length == 100 ? "EAN8" : "EAN13";
}
if (options.valueField) {
// Set companion field value
this.frm.set_value(options.valueField, value);
}
}
return options;
},
isValidJson(jsonData) {
try {
JSON.parse(jsonData);
return true;
} catch (e) {
return false;
}
}
});
But this is the error i get when i use the bench build command
UNRESOLVED_IMPORT : āqrcodejsā is imported by frappe/public/js/frappe/form/controls/qrcodegen.js, but could not be resolved Ć¢ā¬ā treating it as an external dependency
Cannot find some dependencies. You may have to run ābench setup requirementsā to install them.
any clues? thanks
fixed the last one
broke it again.
any good news ?