In this article, you will learn how to add and use email, phone, and URL widgets in Odoo15. We are going to use the built-in widget feature of Odoo in XML code.
Why do we use the Phone, Email, and URL widget?
To make the phone, email, and website fields more precise we have to use these widgets. If we don't use these (phone, email, and URL) widgets then our field looks like a simple character field. To make it more clear we are going to use the below widgets in our XML.
Read More: Color Field and Color Picker (color_picker) Widgets in Odoo
- widget="phone"
- widget="email"
- widget="url"
You can also add options to the fields along with the above widgets.
<field name="phone" widget="phone" options="{'enable_sms': false}"/>
<field name="email" widget="email"/>
<field name="website" widget="url" options="{'website_path': false}"/>
If you want to add an SMS option with the phone widget then you have to set or enable True the "enable_sms" option.
Read More: Decorate Fields in Odoo (Bold, Italic Text and Color) in Tree View Column
<field name="phone" widget="phone" options="{'enable_sms': True}"/>
This will add the SMS icon with the phone field and you will be able to send SMS with a wizard-like below.
Read More: How to Connect and Integrate WhatsApp With Odoo
Similarly, if the "website_path" option in the URL widget is set to True then it appends the path of your website with the field. If you are on localhost:8069, then the "website_path" option will append the localhost:8069 with the entered URL in the website field.
<field name="website" widget="url" options="{'website_path': True}"/>
0 Comments