closes odoo/odoo#102150 X-original-commit: c57a0ada02bfc1f02b3516f92f87b510942c5a87 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
24 lines
715 B
JavaScript
24 lines
715 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.update(barcode);
|
|
}
|
|
}
|
|
|
|
BarcodeHandlerField.template = xml``;
|
|
BarcodeHandlerField.props = { ...standardFieldProps };
|
|
|
|
registry.category("fields").add("barcode_handler", BarcodeHandlerField);
|