in normal case i set barcode in item master
and it works successfully in pos
but the problem is (there are items are weighted
by scale machin ) and scale machine printout label immediatly
contains barcode and weight together in one label
as the picture below
the first 7 degits express the barcode
and last 6 digits express the weight
what i need is
in scanning erpnext divides barcode automatically into
(item code - weight in quantity)
let me say what i did till now
i defined new field in (item master) this field is checkable
(is this scale item) - dependent
on this check i set the number of weight digits and sorting
(barcode digits - weight digit )
Based on my need i have customized this piece of code for barcode weighted items …
Needs improve like
Define and save one or more barcode weighted items starting code like (280)
So the code reads the setting and checks
Right now if your Barcode starts with 280 and your item code is 4 digits it will get the Kgs (5 digits) and figure if they have 4,3,2,1 zero … Hope this helps as it is working for me.
on top of POS declare you var pesokg;
Under get_items: function on the if (key)
if (key) {
console.log('continua procura')
if (key.length == 13){
//Codigo barras por KG; Weighted barcode
if (key.startsWith('280')){
//Talho especifico ... for specific customer or barcode type TO BE REVIEWED
// key.substr(3,4) Codigo do Produto Max 4 digitos; item max 4 digits
return $.grep(this.item_data, function (item) {
if (item.item_code == key.substr(3,4)) {
// guarda os kg para depois; keeps kgs for later
pesokg1 = key.substr(13-6,5)
if (pesokg1.startsWith('0000')){
pesokg='0.' + pesokg1.substr(4)
}else if (pesokg1.startsWith('000')){
pesokg='0.' + pesokg1.substr(3)
}else if (pesokg1.startsWith('00')){
pesokg='0.' + pesokg1.substr(2)
}else if (pesokg1.startsWith('0')){
pesokg=pesokg1.substr(1,1) +'.' + pesokg1.substr(2,pesokg1.length)
}
search_status = false;
return true
}
})
}
}
I can’t seem to get any of these solutions to work. My script behaves as if I have not made any of these changes. I’m not even seeing my console log.
I’m experimenting with a ERPNext v7.2 Virtual Machine.
Editing file: frappe@erpnext:~$ vi frappe-bench/apps/erpnext/erpnext/accounts/page/pos/pos.js POS.js file coming up
Also. Have you made any new updates to the script?
I still have this customer on the same version 8 and is working… i have not updated the script yet.
I have updated my local to v10 and this is still working…
Dont forget that this needs to be on POS.js and on get_items: function
Also if is a local server you need to bench build before bench start so those changes are taken place…
In my case because i have many testing companies i usually before bench start i do bench --site XXX migrate and only after i start bench start.
if(key){
//console.log('continua procura 1');
if (key.length == 13){
//Codigo barras por KG; Weighted barcode
if (key.startsWith('200')){
//Talho especifico ... for specific customer or barcode type TO BE REVIEWED
// key.substr(3,4) Codigo do Produto Max 4 digitos; item max 4 digits
return $.grep(this.item_data, function (item) {
if (item.barcode == key.substr(0,7)) {
// guarda os kg para depois; keeps
pesokg1 = key.substr(7,6)
if (pesokg1.startsWith('0000')){
pesokg='0.' + pesokg1.substr(4)
}else if (pesokg1.startsWith('000')){
pesokg='0.' + pesokg1.substr(3)
}else if (pesokg1.startsWith('00')){
pesokg='0.' + pesokg1.substr(2)
}else if (pesokg1.startsWith('0')){
pesokg=pesokg1.substr(1,1) +'.' + pesokg1.substr(2,pesokg1.length)
}else if (!pesokg1.startsWith('0')){
pesokg=pesokg1.substr(0,2) +'.' + pesokg1.substr(2,pesokg1.length)
}
search_status = false;
return true
}
})
}
}
return $.grep(this.item_data, function(item){
if(search_status){
if(in_list(me.batch_no_data[item.item_code], me.search.$input.val())){
The solution works in V7 so far. My production is in V9.2, and its not bringing up any items. What am I missing?
Because no item is coming up. The barcode matching isnt working. And generally the search of the pos has been disturbed and wont even search items by name.
Please follow all of Helio_Jesus’ steps. For the part going under if (key) {
use my code instead of his, I’ve made a minor enhancement. You’ll also need to adjust the item part and weight part of the barcode accordingly using the first key.substr().
The file to edit is ~/frappe-bench/apps/erpnext/erpnext/accounts/page/pos/pos.js so far this works only in offline mode. Still figuring out online mode only.
I am confused on where exactly to insert the code “for the part going under if (key) {…”
see my code as below and please correct my mistakes
if (key) { //console.log(‘continua procura 1’);
if (key.length == 13){
//Codigo barras por KG; Weighted barcode
if (key.startsWith(‘200’)){
//Talho especifico … for specific customer or barcode type TO BE REVIEWED
// key.substr(3,4) Codigo do Produto Max 4 digitos; item max 4 digits
return $.grep(this.item_data, function (item) {
if (item.barcode == key.substr(3,4)) {
// guarda os kg para depois; keeps
pesokg1 = key.substr(13-6,5)
if (pesokg1.startsWith('0000')){
pesokg='0.' + pesokg1.substr(4)
}else if (pesokg1.startsWith('000')){
pesokg='0.' + pesokg1.substr(3)
}else if (pesokg1.startsWith('00')){
pesokg='0.' + pesokg1.substr(2)
}else if (pesokg1.startsWith('0')){
pesokg=pesokg1.substr(1,1) +'.' + pesokg1.substr(2,pesokg1.length)
}else if (!pesokg1.startsWith('0')){
pesokg=pesokg1.substr(0,2) +'.' + pesokg1.substr(2,pesokg1.length)
}
return $.grep(this.items_list, function (item) {
if (search_status) {
if (in_list(me.batch_no_data[item.item_code], me.serach_item.$input.val())) {
search_status = false;
return me.item_batch_no[item.item_code] = me.serach_item.$input.val()
} else if (me.serial_no_data[item.item_code]
&& in_list(Object.keys(me.serial_no_data[item.item_code]), me.serach_item.$input.val())) {
search_status = false;
me.item_serial_no[item.item_code] = [me.serach_item.$input.val(), me.serial_no_data[item.item_code][me.serach_item.$input.val()]]
return true
} else if (item.barcode == me.serach_item.$input.val()) {
search_status = false;
return item.barcode == me.serach_item.$input.val();
} else if (reg.test(item.item_code.toLowerCase()) || (item.description && reg.test(item.description.toLowerCase())) ||
reg.test(item.item_name.toLowerCase()) || reg.test(item.item_group.toLowerCase())) {
return true
}
}
})
} else {
return this.items_list;
}
},