Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[12.0] pos_tare - Uncaught TypeError #978

Closed
baimont opened this issue Apr 19, 2023 · 5 comments
Closed

[12.0] pos_tare - Uncaught TypeError #978

baimont opened this issue Apr 19, 2023 · 5 comments
Labels
bug stale PR/Issue without recent activity, it'll be soon closed automatically.

Comments

@baimont
Copy link

baimont commented Apr 19, 2023

Stacktrace in pos when selecting a product to weight

Module

pos_tare

Describe the bug

For a POS with Tare Input Method = Scan a barcode to set the tare I get a stacktrace when I choose Cheese by the Slice product (from demo data) because id input_weight_tare cannot be found in the view.

Uncaught TypeError: Cannot set properties of undefined (setting 'value')
http://localhost:8069/pos_tare/static/src/js/screens.js:51
Traceback:
TypeError: Cannot set properties of undefined (setting 'value')
at Class.show (http://localhost:8069/pos_tare/static/src/js/screens.js:51:55)
at Class.show (http://localhost:8069/web/static/src/js/core/class.js:123:38)
at Class.show_screen (http://localhost:8069/point_of_sale/static/src/js/gui.js:116:33)
at Class.click_product (http://localhost:8069/point_of_sale/static/src/js/screens.js:1089:21)
at Object.click_product_action (http://localhost:8069/point_of_sale/static/src/js/screens.js:1062:59)
at HTMLElement.click_product_handler (http://localhost:8069/point_of_sale/static/src/js/screens.js:899:21)

In pos_tare, the problematic line is: this.$("#input_weight_tare")[0].value = this.tare;

image

To Reproduce

Affected versions: 12.0

Steps to reproduce the behavior:

  1. Configure your pos : Electronic Scale and Barcode Scanner must be checked under IoT Box
  2. Set Tare Input Method = Scan a barcode to set the tare
  3. Open your pos and select Cheese by the Slice

Expected behavior
No stacktrace

Additional context
I managed to reproduce on runboat and on local.

Proposition to resolve the issue
The problem is pretty easy to understand: show method is called in js and goes through the problematic line only if there is a tare on this. Since cheese by the slice has a default tare, there is a tare on this. Problem is there is no id input_weight_tare in the view because in the template we show this input only when pos.config.iface_tare_method != 'barcode'.
One way to fix this would be to adapt

if (this.tare) {
    this.$("#input_weight_tare")[0].value = this.tare;
}

it could become

if (this.tare && this.pos.config.iface_tare_method !== 'barcode') {
    this.$("#input_weight_tare")[0].value = this.tare;
}
@baimont baimont added the bug label Apr 19, 2023
@legalsylvain
Copy link
Contributor

Thanks for reporting and the extensive analysis.
make sense ! could you make a PR ?

@baimont
Copy link
Author

baimont commented Apr 19, 2023

Thanks for reporting and the extensive analysis. make sense ! could you make a PR ?

done

@legalsylvain
Copy link
Contributor

thanks !

@github-actions
Copy link

There hasn't been any activity on this issue in the past 6 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days.
If you want this issue to never become stale, please ask a PSC member to apply the "no stale" label.

@github-actions github-actions bot added the stale PR/Issue without recent activity, it'll be soon closed automatically. label Oct 22, 2023
@legalsylvain
Copy link
Contributor

Fixed by #979. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug stale PR/Issue without recent activity, it'll be soon closed automatically.
Projects
None yet
Development

No branches or pull requests

2 participants