[FIX] barcode: allow multiple buttons with the same string and action
Steps to reproduce the bug:
- Enable work order option in manufacturing settings
- Create a manufacturing order and use the product Table
- Open the tablet view
- with the JS instruction, try to simulate the scan of the command
`CONTINUE CONSUMPTION` with this value: `O-BTN.continue`
Problem:
The action continue is not executed because when the tablet view
is loaded, the function _barcodeButtonHandler is triggered in which
we try to call the `activeBarcode` function for all the buttons:
https://github.com/odoo/odoo/blob/c6716847aa5d694650bfe046657f052a03f9ca39/addons/barcodes/static/src/js/barcode_form_view.js#L437-L445
To add each button in a dictionary, we use as key the name + the string
of the button, but as multiple buttons can have the same name and
the same action, only the last button is saved:
https://github.com/odoo/enterprise/blob/2c9d2c5738d378f6f5cdc2ceec00b89cb5fa9536/mrp_workorder/views/mrp_workorder_views.xml#L137-L150
https://github.com/odoo/odoo/blob/c6716847aa5d694650bfe046657f052a03f9ca39/addons/barcodes/static/src/js/barcode_form_view.js#L252-L255
Solution:
To allow having multiple buttons with a similar name and action,
we must add in the key the attrs hash of the button
opw-2899297
closes odoo/odoo#96778
X-original-commit: 6ff5e0a7c499f95017c09fafd9605bd51be9bfd0
Signed-off-by: Géry Debongnie <ged@odoo.com>
Signed-off-by: Djamel Touati (otd) <otd@odoo.com>