-
- Downloads
[FIX] base: convert barcode type if incorrect encoding
To reproduce the issue: (Need stock_barcode) 1. Create a product: - Barcode: 1234567890123 2. Print the label 3. Try to scan the barcode and check the value read. Error: The value is 1234567890128, the last digit is incorrect (8 instead of 3) When printing a barcode, we use the library 'report-lab' to generate a barcode image from a value and a barcode type. In case of EAN-13, if the value contains a non-digit character, it will raise an error. We then catch the error and retry to generate the barcode according to the barcode type Code128: https://github.com/odoo/odoo/blob/87698d90f02bfe93c6e643f4876a5ccd74788eff/odoo/addons/base/models/ir_actions_report.py#L569-L575 However, if the value contains only digits, the method will use the 12 first digits: https://github.com/mattjmorrison/ReportLab/blob/dade0f303cb6fcdbe535c4cc92e6102c2417b699/src/reportlab/graphics/barcode/eanbc.py#L187-L188 and will then add the last one, the check digit, which is computed by the library. This explains why, in the above use case, the barcode value returned by the scanner is not the same than the expected one. Note: Similar behavior with type EAN-8 OPW-2902150 closes odoo/odoo#95957 Signed-off-by:Steve Van Essche <svs@odoo.com>
Showing
- addons/barcodes/models/barcode_nomenclature.py 4 additions, 41 deletionsaddons/barcodes/models/barcode_nomenclature.py
- addons/barcodes/tests/test_barcode_nomenclature.py 0 additions, 7 deletionsaddons/barcodes/tests/test_barcode_nomenclature.py
- odoo/addons/base/models/ir_actions_report.py 58 additions, 0 deletionsodoo/addons/base/models/ir_actions_report.py
- odoo/addons/base/tests/test_reports.py 20 additions, 0 deletionsodoo/addons/base/tests/test_reports.py
Loading
Please register or sign in to comment