Enable Dark Mode!
form-view-attributes-in-odoo-17.jpg
By: Cybrosys Technologies

Form View Attributes in Odoo 17

Technical Odoo 17

Odoo, a versatile and robust open-source business management software, empowers users to customize their interfaces for a seamless user experience. One pivotal aspect of this customization is the use of Form View attributes. In Odoo 17, understanding and harnessing these attributes is essential for tailoring the application to your specific business needs.
Below is an example of a basic form view in Odoo. This form view is for a simple model named product.product with fields for the product name.
<record id="product_product_view_form" model="ir.ui.view">
            <field name="name">product.product.view.form</field>
            <field name="model">product.product</field>
            <field name="arch" type="xml">
                <form>
                    <group>
                        <!-- Field for Product Name -->
                        <field name="name"/>
                    </group>
                </form>
            </field>
        </record>
By default, when no specific form attributes are set, the form provides functionalities to create a new record, edit existing ones, delete, and duplicate. 
These views can be customized using various attributes, allowing developers to control the layout, behavior, and presentation of data. Here, we'll delve into some of the essential Form View attributes that play a crucial role in shaping the user interface.

1. create (default: True)

The create attribute in a field definition controls whether a field is visible during the creation of a new record. Setting create="false" means the field won't be shown in the creation form.
<form create="0">
        -----------------
 </form>

2. edit (default: True)

The edit attribute plays a crucial role in determining the editability of a field within a form view. When set to false, it renders the field as read-only, restricting any user modifications in the form. In simpler terms, if a field has edit="false", it means users can only view the information but cannot make changes to it in the form view.
<form edit="0">
        -----------------
 </form>

3. string (default: ' ' )

The string attribute serves as a way to provide a user-friendly title or label for a form view. This label is usually visible at the top of the form, offering users a clear and human-readable description of the data they are interacting with.
<form string="Form Attributes">
        -----------------
 </form>

4. duplicate (default: True)

This attribute serves to control the availability of the "Duplicate" option for a record within the form view. When set to true, users can create copies or duplicates of the current record as needed. On the other hand, if set to false, the option to duplicate the record won't be accessible through this particular form view, limiting users from creating replicas of the existing data.
<form duplicate="0">
        -----------------
 </form>

5. delete (default: True)

The delete attribute serves as a key determinant of the availability of the "Delete" option within the context of a form view. By default, this attribute is configured to be true, granting users the capability to delete the current record using the associated form view. However, when set to false, users are restricted from deleting the record through this specific form view.
<form delete="0">
        -----------------
 </form>

6. js_class (optional)

This attribute allows developers to define custom behavior using JavaScript for a specific view, enhancing the interactivity and functionality of the user interface.
Here is an example of how the js_class attribute can be utilized in a view definition:
<record id="view_custom_model_form" model="ir.ui.view">
    <field name="name">custom.model.form</field>
    <field name="model">custom.model</field>
    <field name="arch" type="xml">
        <form js_class="FormController">
            <!-- Form fields and structure -->
        </form>
    </field>
</record>
For more details about js_class attributes, refer to How to Extend Odoo Form View Using js_class?

7. disable_autofocus (default: False)

When you open a form or page, it won't automatically highlight or select the first box where you usually type information. Instead, you have the freedom to choose where you want to start typing or interacting without the system automatically guiding you to the first field. It gives you more control over where you want to input information in the view.
 <form disable_autofocus="1">
        —---------------
 </form>
Form views in Odoo are the gateway to efficient data management and user interaction. By understanding their structure, leveraging customization attributes, and applying advanced techniques, you can craft interfaces that not only meet but exceed user expectations.


If you need any assistance in odoo, we are online, please chat with us.



0
Comments



Leave a comment

 


whatsapp
location

Calicut

Cybrosys Technologies Pvt. Ltd.
Neospace, Kinfra Techno Park
Kakkancherry, Calicut
Kerala, India - 673635

location

London

Cybrosys Limited
Alpha House,
100 Borough High Street, London,
SE1 1LB, United Kingdom

location

Kochi

Cybrosys Technologies Pvt. Ltd.
1st Floor, Thapasya Building,
Infopark, Kakkanad,
Kochi, India - 682030.

location

Bangalore

Cybrosys Techno Solutions
The Estate, 8th Floor,
Dickenson Road,
Bangalore, India - 560042

Send Us A Message