[12.0] pos_tare - Uncaught TypeError
baimont opened this issue · 5 comments
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;
To Reproduce
Affected versions: 12.0
Steps to reproduce the behavior:
- Configure your pos : Electronic Scale and Barcode Scanner must be checked under IoT Box
- Set Tare Input Method = Scan a barcode to set the tare
- 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;
}
Thanks for reporting and the extensive analysis.
make sense ! could you make a PR ?
Thanks for reporting and the extensive analysis. make sense ! could you make a PR ?
done
thanks !
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.
Fixed by #979. Closing.