odoo

Views in Odoo: A Complete Guide to Odoo View Types

In Odoo, the user interface (actions, menus and views) is largely defined by creating and composing records defined in an XML file. A common pattern is Menu > Action > View. To access records the user navigates through several menu levels; the deepest level is an action which triggers the opening of a list of the records.

There are various types of views in odoo, among them some are listed here after:

1.tree/list view

   <record id="view_country_tree" model="ir.ui.view">
            <field name="name">res.country.list</field>
            <field name="model">res.country</field>
            <field name="arch" type="xml">
                <list string="Country" create="0" delete="0">
                    <field name="name"/>
                    <field name="code"/>
                </list>
            </field>
        </record>

 

2.Form View


        <record id="view_country_form" model="ir.ui.view">
            <field name="name">res.country.form</field>
            <field name="model">res.country</field>
            <field name="arch" type="xml">
                <form create="0" delete="0">
                    <sheet>
                        <div class="oe_button_box" name="button_box">
                        </div>
                        <field name="image_url" widget="image_url" class="oe_avatar" options="{'size': [128,128]}"/>
                        <group name="main_group">
                        </group>
                        <group name="advanced_address_formatting" string="Advanced Address Formatting" groups="base.group_no_one">
                        </group>
                    </sheet>
                </form>
            </field>
        </record>

3.Search View

     <record id="view_country_search" model="ir.ui.view">
            <field name="name">res.country.search</field>
            <field name="model">res.country</field>
            <field name="arch" type="xml">
                <search string="Countries">
                    <field name="name" filter_domain="['|', ('name', 'ilike', self), ('code', 'ilike', self)]"/>
                    <field name="phone_code"/>
<group string="Group By">
                        <filter name="groupby_country" string="Country" context="{'group_by': 'country_id'}"/>
                    </group>                    
                </search>
            </field>
        </record>

 

 

Actions

        <record id="action_country" model="ir.actions.act_window">
            <field name="name">Countries</field>
            <field name="res_model">res.country</field>
            <field name="help" type="html">
                <p class="o_view_nocontent_smiling_face">
                    No Country Found!
                </p><p>
                    Manage the list of countries that can be set on your contacts.
                </p>
            </field>
        </record>

 

 

 

inheritance

        <record id="action_country" model="ir.actions.act_window">
            <field name="name">Countries</field>
            <field name="res_model">res.country</field>
            <field name="help" type="html">
                <p class="o_view_nocontent_smiling_face">
                    No Country Found!
                </p><p>
                    Manage the list of countries that can be set on your contacts.
                </p>
            </field>
        </record>

 

difference way to inherit 

<field name="arch" type="xml">
                <div name="button_box" position="inside">
                    <button class="oe_stat_button" type="object" name="action_view_invoice"
                        icon="fa-pencil-square-o" invisible="invoice_count == 0">
                        <field string="Customer Invoices" name="invoice_count" widget="statinfo"/>
                    </button>
                    <button class="oe_stat_button" type="object" name="action_view_vendor_bill"
                        icon="fa-file-text-o" invisible="vendor_bill_count == 0">
                        <field string="Vendor Bills" name="vendor_bill_count" widget="statinfo"/>
                    </button>
                </div>
            </field>
<field name="arch" type="xml">
                <field name="debit" position="attributes">
                    <attribute name="column_invisible">False</attribute>
                </field>
                <field name="credit" position="attributes">
                    <attribute name="column_invisible">False</attribute>
                </field>
            </field>
<field name="arch" type="xml">
                <data>
                    <xpath expr="//field[@name='partner_id']" position="before">
                        <field name="prefix_placeholder" column_invisible="1"/> <!-- Needed for the char_with_placeholder_field widget -->
                        <field name="account_prefix" string="Accounts Prefixes" optional="show" widget="char_with_placeholder_field" options="{'placeholder_field': 'prefix_placeholder'}"/>
                    </xpath>
                    <xpath expr="//field[@name='company_id']" position="before">
                            <field name="product_id" optional="show"/>
                            <field name="product_categ_id" optional="hide"/>
                    </xpath>
                </data>
            </field>

 

 <field name="inherit_id"


About author

author image

Amrit panta

Fullstack developer, content creator



Scroll to Top