Adding content and widgets to a form view

The previous recipe showed how to pick a specific view for an action. Now we'll demonstrate how to make the form we defined previously more useful.

How to do it...

  1. Define the form view basic structure:
    <record id="form_all_customers" model="ir.ui.view">
      <field name="name">All customers</field>
      <field name="model">res.partner</field>
      <field name="arch" type="xml">
        <form>
          <!--form content goes here -->
        </form>
      </field>
    </record>
  2. To add a head bar, usually used for action buttons and stage pipeline, add inside the form:
          <header>
            <button type="object" 
                    name="open_commercial_entity"
                    string="Open commercial partner"       
                    class="oe_highlight" />
          </header>
  3. Add fields to the form, using group tags to visually organize them: ...

Get Odoo Development Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.