Files
odoo_source/addons/barcodes/static/src/barcode_handler_field.js
T
Jorge Pinna Puissant 04d5fb2255 [FIX] *: simplify concrete field API - remove update prop
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>
2023-03-23 09:06:52 +01:00

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);