Skip to content

Commit

Permalink
[IMP] stock_barcodes: Avoid NewId environment calling method on_barco…
Browse files Browse the repository at this point in the history
…de_scanned instead of onchange

Onchange limits documented in method:
It is not possible for a ``one2many`` or ``many2many`` field to modify
itself via onchange. This is a webclient limitation - see `#2693 <https://github.com/odoo/odoo/issues/2693>`_.

This causes refresh problems when creating or modifying records, and it is also not ideal to create records in "onchange mode"
  • Loading branch information
carlosdauden committed Oct 1, 2024
1 parent cdf8d13 commit 04c0fe7
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions stock_barcodes/static/src/utils/barcode_handler_field.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ patch(BarcodeHandlerField.prototype, "stock_barcodes.BarcodeHandlerField", {
setup() {
this._super(...arguments);
const busService = useService("bus_service");
this.orm = useService("orm");
const notifyChanges = async ({detail: notifications}) => {
for (const {payload, type} of notifications) {
if (type === "stock_barcodes_refresh_data") {
Expand All @@ -26,4 +27,15 @@ patch(BarcodeHandlerField.prototype, "stock_barcodes.BarcodeHandlerField", {
};
});
},
onBarcodeScanned(event) {
const {barcode} = event.detail;
if (this.props.record.resModel.includes("wiz.stock.barcodes.read")) {
this.orm.call(this.props.record.resModel, "on_barcode_scanned", [
this.props.record.resId,
barcode,
]);
} else {
this._super(...arguments);
}
},
});

0 comments on commit 04c0fe7

Please sign in to comment.