Since [1], the update props is not used anymore in the field API. Some utilization were missing in the refactoring. [1]: https://github.com/odoo-dev/odoo/commit/b5db53b5df6403d2d9b57771854bc36aa5d83583 task-id 3241162 closes odoo/odoo#116229 X-original-commit: d212e46119a187452eb6c6d52b8592f28a633dd0 Related: odoo/enterprise#38579 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
28 lines
822 B
JavaScript
28 lines
822 B
JavaScript
/** @odoo-module **/
|
|
|
|
import { registry } from "@web/core/registry";
|
|
import { standardFieldProps } from "@web/views/fields/standard_field_props";
|
|
import { useBus, useService } from "@web/core/utils/hooks";
|
|
|
|
const { Component, xml } = owl;
|
|
|
|
export class BarcodeHandlerField extends Component {
|
|
setup() {
|
|
const barcode = useService("barcode");
|
|
useBus(barcode.bus, "barcode_scanned", this.onBarcodeScanned);
|
|
}
|
|
onBarcodeScanned(event) {
|
|
const { barcode } = event.detail;
|
|
this.props.record.update({ [this.props.name]: barcode });
|
|
}
|
|
}
|
|
|
|
BarcodeHandlerField.template = xml``;
|
|
BarcodeHandlerField.props = { ...standardFieldProps };
|
|
|
|
export const barcodeHandlerField = {
|
|
component: BarcodeHandlerField,
|
|
};
|
|
|
|
registry.category("fields").add("barcode_handler", barcodeHandlerField);
|