Enable Dark Mode!
what-are-the-essential-form-view-attributes-in-odoo-16.jpg
By: Arwa VV

What Are the Essential Form View Attributes in Odoo 16

Technical Odoo 16

In Odoo 16, one of the fundamental aspects of tailoring your experience in Odoo is understanding and utilizing Form Attributes in Odoo 16. Form Attributes are like the building blocks of your data forms. They determine how you interact with your records, whether it's creating new ones, editing existing ones, duplicating, or even deleting them. In this blog, we'll take a closer look at these essential attributes.

1. Create: This attribute defines whether the "Create" option should be available in the form view. If set to false, the user won't be able to create new records using this form view. This attribute will always be true by default. 

2. Write: This attribute determines whether the "Save" or "Edit" option is available. If set to false, the user won't be able to modify existing records using this form view. By default, it is set to true.

3. Edit: This attribute, if used, is used to determine if the view is editable. It's similar to the write attribute. By default, it is set to true.

4. String: The string attribute is used to define a human-readable title or label for the form view. This label is typically displayed at the top of the form to give users context about the data they are working with. 

5. js_class: This attribute specifies the JavaScript class to be applied to the form view. It can be used to attach custom JavaScript behavior to the form view.

You can learn more about js_class by referring to our blog on How To Extend Odoo Form View using  js_class. ? which covers the basics and its usage."

6. Duplicate: This attribute is used to determine whether the "Duplicate" option is available. Users can create duplicates of the current record if required. By default, this attribute will be true. If set to false, users won't be able to create duplicates of the current record using this form view. 

7. Delete: This attribute is used to determine whether the "Delete" option is available. By default, this attribute will be true. If set to false, users won't be able to delete the current record using this form view.

By default, without setting any form attributes, we have the option to create a new record, edit, delete, and duplicate it. In the below code, we haven’t specified any attributes.

<record id="form_attribute_view_form" model="ir.ui.view">
   <field name="name">form.attribute.view.form</field>
   <field name="model">form.attribute</field>
   <field name="arch" type="xml">
       <form string="Form Attributes">
           <sheet>
               <group>
                   <field name="name"/>
                   <field name="date"/>
               </group>
           </sheet>
       </form>
   </field>
</record>

In this case, we can see the option ‘New’ at the top right corner of the Form view to create a new record, and also the option to delete and duplicate the record, under the ‘Action’ menu. In addition, the option to edit the record is also available.

What Are the Essential Form View Attributes in Odoo 16-cybrosys

If you want those attributes to be disabled, you can set them to 0 as follows:

<record id="form_attribute_view_form" model="ir.ui.view">
   <field name="name">form.attribute.view.form</field>
   <field name="model">form.attribute</field>
   <field name="arch" type="xml">
       <form string="Form Attributes" create="0" write="0" delete="0" duplicate="0">
           <sheet>
               <group>
                   <field name="name"/>
                   <field name="date"/>
               </group>
           </sheet>
       </form>
   </field>
</record>

As we can see, the options to create, edit, delete, and duplicate are not available in this case.

What Are the Essential Form View Attributes in Odoo 16-cybrosys

By using these attributes in your form view definitions, you can finely control the user experience, deciding which actions users can perform on records. By understanding and strategically using these attributes, you can tailor Odoo to match your specific business requirements, ensuring a seamless and efficient workflow for users.


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



0
Comments



Leave a comment



whatsapp_icon
location

Calicut

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

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