Skip to content
ERPForAll DocsDevelopment

    Static form layout

    Human form views support this declared subset under ADR0072 and the supplementary region under ADR 0104:

    <form>
    <sheet>
    <field name="name"/>
    <group>
    <group string="Details"><field name="priority"/></group>
    <group string="Organization"><field name="company_id"/></group>
    </group>
    <notebook>
    <page name="description" string="Description"><field name="body"/></page>
    <page name="internal" string="Internal Memo" groups="base.group_system">
    <field name="internal_memo"/>
    </page>
    </notebook>
    </sheet>
    <aside>
    <group string="Record information">
    <field name="create_uid" readonly="1"/>
    <field name="create_date" readonly="1"/>
    <field name="write_uid" readonly="1"/>
    <field name="write_date" readonly="1"/>
    </group>
    </aside>
    </form>

    An optional aside belongs directly to a record form, at most once. Put it after sheet content and before an optional footer. Direct children are fields, groups and separators; groups retain the existing grammar. Static groups/invisible prune its subtree on the server. Unknown attributes, nested/duplicate asides and service-form asides refuse. Ordinary field permissions remain authoritative. Inherited views can insert an aside with an XPath after //sheet or extend its groups. Both appearances place it beside the sheet on wide screens and stack it on narrow screens. Fields share the parent record’s draft/save and validation lifecycle. The four fields in this example require model log access and are record information, not a complete event audit or approval workflow.

    <form>
    <sheet>...</sheet>
    <chatter reload_on_post="1" open_attachments="0"/>
    </form>

    <chatter/> belongs directly to a record form, at most once, and may sit beside an aside. It has no children and takes only the flags reload_on_post, reload_on_attachment, reload_on_activity, reload_on_follower and open_attachments (default false). Each flag accepts only 1, 0, true, false, True or False; any other text refuses, unlike Odoo, which treats any non-empty text as true. groups and invisible are not accepted. The model must inherit mail.thread, otherwise get_views fails with View element <chatter> requires model '<model>' to inherit 'mail.thread'. The server sets has_activities from mail.activity.mixin; it is never written in the XML. Refusals appear when views are served, not when the XML view is saved. Placement under sheet, aside, group or page and in service forms refuses.

    This slice delivers the node and an empty slot only (side column under the aside on wide Office Blue, after the sheet on narrow screens and the Default theme; none in dialogs, x2many forms or the relation editor). Messages, followers and activities are planned, and no registered model inherits mail.thread yet. Older clients refuse the unknown chatter node, so ship the client with the server. A <chatter> inside a conditional wrapper (<t groups="...">) is refused. The side-column placement (wide Office Blue only) has no browser check yet: Playwright check not run. Spec cases: SPEC-FORMXML-008, -009, -010; ADR 0104 addendum.

    Sheet belongs directly to form. Groups accept optional name/string and static col/colspan. Columns are even label/control track counts2..12; two tracks make one field column. Default col is4 when a group has child groups, otherwise2. Default colspan2 applies inside parent groups; top-level groups occupy the sheet row. Put groups inside one outer group for side-by-side sections. Phone layout becomes one column.

    Notebook contains page elements only. A page needs name or string; an absent caption uses its name, and visible names within one notebook must be unique. Static groups and invisible on containers are evaluated server-side before descendant field lookup. A separator has optional string/name and occupies its group’s row. Arbitrary HTML, classes, odd track counts and dynamic layout modifiers remain explicitly unsupported. List and service views retain their existing closed grammar.

    The first name/char field remains the human client’s prominent title; registered custom widgets continue to render inside the declared container. Field widgets retain required, readonly and native validation behavior. Notebook changes preserve draft edits and selected page through onchange; they do not save. On save, the first invalid field’s page opens before native validity feedback. Existing save/discard/navigation rules still apply.

    This is not whole Odoo form parity. The smart-button subset below is supported; broader statusbar, arbitrary templates, chatter and relational subview behavior remains subject to the individual form slices.

    Static per-view field modifiers are part of the human metadata contract (ADR 0091).

    Declare readonly, required, invisible and force_save on each field occurrence. The existing static boolean spellings are 0, 1, false, true, False, True. Omitted readonly/required inherit model presentation metadata; explicit false overrides it in that view. Omitted invisible/force_save are false. Record forms also accept dynamic readonly, required and invisible expressions (ADR 0124); force_save stays a literal. List views refuse dynamic field expressions until rows evaluate them (views guide). These field rules do not alter the container pruning rules above.

    <field name="reference" readonly="1" force_save="1"/>
    <field name="note" required="0"/>
    <field name="internal_token" invisible="1"/>

    An invisible authorized field keeps its read/default/onchange/draft values, with no rendered control/column. Hiding it does not make it secret. Group and server field access are the security boundary. View required false removes client validation only; server ORM requirements still apply. Readonly prevents control edits; it does not grant or revoke write permission. force_save lets present readonly defaults/onchange/draft changes participate in save/create; it never makes the control editable. Without force_save readonly changes are omitted from save, while onchange still includes readonly state. id always stays readonly and is never written.

    Repeated nodes keep individual presentation, while the view’s record policy combines readonly and invisible with AND, required and force_save with OR. Use consistent required flags where possible: any required occurrence makes the combined visible field required. Form/list and relational line policies are independent. Existing relation command/value normalization applies.

    Functional documentation gap: docs/user/forms.md does not yet exist; a user page should explain required markers, readonly values, hidden values, server save refusals and draft retention. This authoring guide does not establish a delivered user-facing capability.

    A one2many in a form shows its lines with the comodel’s default list and edits a line in the comodel’s default form. When two fields of one form point at the same comodel and must show different columns (the product lines and the journal items of an invoice are both account.move.line), a field names the views of its lines in its context, with the keys Odoo uses:

    <field name="invoice_line_ids"
    context="{'list_view_ref': 'account.view_invoice_line_list', 'form_view_ref': 'account.view_invoice_line_form'}"/>

    The values are qualified XML ids of views of the comodel. The client asks the comodel’s views with these keys, the server selects the named views, and a name that does not resolve is refused by the server. A field without them keeps the default views. The context must be a constant: one that reads a record value is not used for the views.

    A group of amounts (<group string="Totals"> with monetary fields) is an ordinary leaf group: one field per row, label and value on the group’s two tracks.

    Declare <div class="oe_title"><h1><field name="display_label"/></h1></div> inside a record form or sheet. Field names are ordinary model metadata, not a reserved convention. h2 is also supported; title children can be ordinary fields or headings, and headings contain fields. The div accepts only exact class oe_title, name, groups and static invisible; headings accept name, groups and static invisible. Normal XML inheritance and field authorization still apply. Titles remain inside their declared form/sheet, group or page scope. Main record routes keep the editable title out of the command header and preserve native form ownership and validation. A view without this declaration keeps its previous title fallback at the existing field occurrence. Spans, literal text, extra classes, dynamic labels and richer upstream title markup are not supported and fail explicitly. See ADR 0106. This does not add field permissions.

    A named area belongs directly inside a record-form sheet. Addons may insert into it with <xpath expr="//div[@name='button_box']" position="inside"> or alter a button’s attributes using normal view inheritance. The combined arch determines ordering and placement.

    <sheet>
    <div name="button_box" class="oe_button_box">
    <button name="open_lines" type="object" class="oe_stat_button"
    invisible="line_count == 0">
    <field name="line_count" widget="statinfo" string="Lines"/>
    </button>
    </div>
    <group><field name="name"/></group>
    </sheet>

    The example requires an actual model integer/float line_count and an RPC-exposed open_lines method. Neither is generated by XML. The server applies groups to containers, buttons and fields. Record-dependent button invisible expressions can only use fields admitted in this view. The button caption comes from its explicit string or the first statistic field’s explicit string. Statistics are readonly; zero is displayed as zero and missing values as an em dash. Do not add required, readonly or force_save attributes to statistic fields.

    Clicks use the existing object-button path: confirmation, save for a dirty/new record, public method RPC and the normalized action-result handler. type="action", contexts, icons, percent widgets and arbitrary nested HTML remain unsupported with an explicit error. A data-only addon needs a real supported action/field provider before it can show a counter; XML never invents values from relation lengths or labels. Buttons wrap within their sheet; the Odoo overflow menu and dialog-specific hiding are not implemented.

    Operations: install/upgrade changed view XML through the normal addon lifecycle; no new server settings or services. Functional-page gap remains docs/user/forms.md: the future page must explain related-record action values, save-before-action, access filtering and error behavior.

    ADR 0108 adds the ERPForAll-specific read-only record method relation_count. For a registered direct one2many loan_ids on an installed book model, send:

    {"ids": [42], "field": "loan_ids"}

    Use /erp/json/2/<book-model>/relation_count. The response is a nonnegative integer counting target records visible to the caller, including model/field, record/company and active filtering. Target ACL is checked even at zero. Errors remain errors. No schema, settings, grants or data migration is introduced.

    Only a stored direct O2M with a stored M2O inverse is supported. Computed, related, inherited, nonstored, field-domain/context relations and other relation types refuse explicitly. Dirty unsaved relations are not counted. Every call reads its transaction snapshot; later navigation can see concurrent committed changes.

    This method is an ERPForAll extension, with no standard Odoo method/widget parity claim. It does not change numeric statinfo behavior or register a fake count field. Use the explicit ERPForAll provider inside a smart button:

    <div name="button_box" class="oe_button_box">
    <button name="open_loans" type="object" class="oe_stat_button" string="Loans">
    <field name="loan_ids" widget="relation_count" string="Loans"/>
    </button>
    </div>

    The object method must be genuinely exposed by the installed addon. Count-only relations are excluded from normal record reads/defaults/onchange/write payloads. If another occurrence is an ordinary sublist, it retains its own read/edit policy. The component shows loading and error states, guards old responses and refetches on render after save/reload/action return. New forms display an em dash and disable this related action until saved. Dirty unsaved relation edits are counted after save. Error details stay visible in the existing error surface and statistic tooltip.

    Library’s base1.0.3 adds the named empty box; optional package1.3.6 inserts the Loans button and an exposed open_loans action through XPath. Stage the matching server/client first, then perform the coordinated native sample_library update with the verified previous release identity before upgrading the stored package. Only then reopen human forms and activate the release under the existing lifecycle procedure. The prior base lacks the XPath target; upgrading only the package is unsupported and must fail, rather than silently inserting a second region. No schema/grants/settings change is needed; installed-content identities and addon version/source receipts must follow the standard upgrade path. Browser/package acceptance status is recorded in docs/design/relation-count.md.