ERPNext Foundation ERPNext Cloud User Manual Blog Discuss Frappé* Donate

How can manage barcode for weighed items in POS?



This looks right @EnSeal


With this script the PoS page comes up blank


@olamide_shodunke On why the POS is blank, my guess is that you have missed something on the code, code is very sensitive to the last character. The best way to know is to check the console both in Chrome and Firefox. You can share the screenshots here.

Also Put the POS in Offline-Mode.



here is a screenshot


Yes. You’ve definitely missed a character or deleted one in the process.
Just look closely and compare with another setup. The code hasn’t changed
much up to v10. This works in v10 as well. Which I must ask, how stable is


Online PoS is quite stable .

Offline not so much


Hi @adam26d did you get manage to fix it?


Would be great to have this Implemented as part of the standard and also the possibility of not selling items with stock Zero.


I think Zero item sales is a good idea that needs to be an option in POS Settings. Like we have in Stock Settings. In a walk-in retail store businesses that cannot accommodate entering missed Stock Receipts as customers wait. The POS must just work, record draft with errors and alert the responsible user by Email or Chat.

This discussion needs its own thread.


Agreed. Upvote the issue by giving a thumbs up emoji on GitHub POS for weighed items #6910


@rohit_w we have been able to make this work …unfortunately it only works on offline PoS.

You seem to be the go to guy for PoS matters…What do we need to do to make this work for online PoS.

Will appreciate any hint


@adam26d @Helio_Jesus

Trust you are good…

This scripts works except for the issue not being able to scan or click items without quantities. I observed when an item with zero quantity is scanned or Clicked on the POS page more than once, the quantity does not increase.

In same vain if an item with Qty 2 is scanned more than twice, it doesn’t increase its quantity more than 2.

This is a big loop hole we will appreciate a fix on…

Anticipating your positive response


Did you copy all the code for the script ?
My script does not allow stock ZERO to sell… if you want you must remove the conditition that checks for this.
Now if the below code was copied it should +add the Qty …
Please check below code is copied and test again… remember Stock zero (Sell only stock available) to be removed.

To add the result add the below changes:

Add Before frappe.pages
var pesokg;
frappe.pages[‘pos’].on_page_load = function (wrapper) {

ON add_to_cart: function after caught = true; replacing d.qty += 1; by below
if (pesokg) {
if (d.qty == undefined){
d.qty = Number(pesokg);
d.qty += Number(pesokg);
pesokg =0;
d.qty += 1;
//Sell only stock available
if (d.qty > me.get_actual_qty(me.items[0])){
d.qty -= 1;

On add_new_item_to_grid: function after this.child.discount_percentage = 0.0; and replacing this.child.qty = 1; by below

if (pesokg) {
if (this.child.qty == undefined){
this.child.qty = Number(pesokg);
this.child.qty += Number(pesokg);
pesokg =0;
this.child.qty = 1;



thank you for your swift response

What i have done is change

d.qty -= 1: to d.qty -= 0 and this seems to work for me



Most welcome to help.


@adam26d @Helio_Jesus bro can you share complete file if its possible.


The code was shared here … as my file is full of modifications that will not suite most.
Have a look from the beginning of the posts.


Just made this for you buddy. Now just edit the lengths and codes according to your barcode. You can start with my 13 digit barcode for testing.

Tip: Use javascript console print outs to see what’s happening in your variables. Please google it if you need to learn how.

Credits due to @Helio_Jesus. Thanks again!


dear @adam26d ,
Thank you for quick and wonderful response, but bro unfortunately its showing blank page when i open POS :frowning:


Dear @zahidshuja

I have seen this before, the reason is that your Javascript is broken. Probably by a wrongly placed character, could be an unclosed block of code, an opening " without a closing one, or something of the sort. What can you see in your browser console? Check using both Chrome and Firefox.

If you pasted this code, double check the begining and end of your script to ensure its exactly as from the source file.