fields
forms
Phone
Odoo 19 fields — Phone (views)
Live preview
Interactive
Source excerpt
web/static/src/views/fields/phone/phone_field.js
import { registry } from "@web/core/registry";
import { _t } from "@web/core/l10n/translation";
import { useInputField } from "../input_field_hook";
import { standardFieldProps } from "../standard_field_props";
import { Component } from "@odoo/owl";
export class PhoneField extends Component {
static template = "web.PhoneField";
static props = {
...standardFieldProps,
placeholder: { type: String, optional: true },
};
setup() {
useInputField({ getValue: () => this.props.record.data[this.props.name] || "" });
}
get phoneHref() {
return "tel:" + this.props.record.data[this.props.name].replace(/\s+/g, "");
}
}
export const phoneField = {
component: PhoneField,
displayName: _t("Phone"),
supportedOptions: [
{
label: _t("Dynamic Placeholder"),
name: "placeholder_field",
type: "field",
availableTypes: ["char"],
},
],
supportedTypes: ["char"],
extractProps: ({ placeholder }) => ({
placeholder,
}),
};
registry.category("fields").add("phone", phoneField);
class FormPhoneField extends PhoneField {
static template = "web.FormPhoneField";
}
export const formPhoneField = {
...phoneField,
component: FormPhoneField,
};
registry.category("fields").add("form.phone", formPhoneField);
Registry / API
- Registry name
phone- Category
fields- Module
web- Slug
phone- Nav group
forms