Field attributes
Reference for the field element inside view arch XML. The Go parser (core/engine/parser/view_xml.go) and serializer (core/engine/swcmeta/arch.go) convert these attributes into JSON on arch.fields[]; SWC field widgets read that JSON at runtime.
For ORM field types (Char, Many2one, …), see Field types. For widget behaviour, see SWC widget catalog.
Attribute reference
| Attribute | Required | Values | Effect |
|---|---|---|---|
name | yes | model field name | Selects which column to read/write. Must exist on the view's model. |
string | no | label text | Overrides the model field label in this view only. |
widget | no | registry key | Swaps the default control. See widget catalog. |
placeholder | no | hint text | Grey hint in empty inputs. Does not set a default value. |
readonly | no | 1, true, yes, on | Field displays but cannot be edited in this view. |
required | no | 1, true, yes, on | Client-side required validation before save (merged with model Required). |
invisible | no | 1, true, yes, on | Hidden from UI; value may still load from server. |
options | no | key:value,... | Widget-specific settings (see widget catalog). |
groups | no | ACL group xml id | Field hidden unless user has the group. |
type | pivot only | row, col, measure | Pivot/graph axis role. |
Basic examples
<field name="name" string="Company name" placeholder="Acme Corp"/>
<field name="email" widget="email" placeholder="name@example.com"/>
<field name="active" widget="boolean_toggle"/>
<field name="create_date" readonly="1"/>
<field name="internal_ref" invisible="1"/>
<field name="phone" widget="phone" required="1"/>
Options syntax
options is a comma-separated list of key:value pairs (no JSON required):
<field name="state" widget="statusbar" options="clickable:1"/>
<field name="priority" widget="priority" options="mode:stars,stars:5"/>
<field name="partner_id" widget="many2one"
options="domain:[('company_id','=', $company_id$)]"/>
The $field_name$ placeholder in domain strings is replaced at runtime with the current record value (core/swc/src/model/modifiers.ts).
One2many subview
Embed a nested list inside a one2many field:
<field name="order_line_ids">
<list editable="bottom">
<field name="product_id"/>
<field name="quantity"/>
<field name="price_unit"/>
</list>
</field>
| Subview attribute | Values | Effect |
|---|---|---|
editable | top, bottom | Inline edit row position in the embedded list |
If you omit the nested , SWC auto-generates up to six scalar columns from the comodel (swcmeta/enrichOne2ManyField).
is accepted as an alias for in the parser.
Header and footer fields
Fields inside serialize to arch.header.fields[] (e.g. statusbar). Fields in the form serialize through groups, notebook pages, and divs.
JSON shape (workspace payload)
Each field becomes an SwcArchField object:
{
"name": "partner_id",
"string": "Customer",
"type": "many2one",
"widget": "many2one",
"relation": "res.partner",
"placeholder": "",
"readonly": false,
"required": false,
"invisible": false,
"options": { "relation": "res.partner" }
}
See Arch JSON pipeline for the full payload.
Dynamic modifiers (*_expr)
The Go serializer (core/engine/swcmeta/arch.go) emits readonly_expr, required_expr, and invisible_expr on arch.fields[] when the XML attribute is a non-literal expression. Boolean literals (1, true, 0, false, …) stay on readonly / required / invisible. SWC's client (model/modifiers.ts) evaluates those expression strings.
<field name="partner_id" readonly="state == 'done'"/>
<field name="amount" required="type == 'invoice'"/>
<field name="reason" invisible="state != 'lost'"/>
Those become ReadonlyExpr / RequiredExpr / InvisibleExpr on the JSON field. Static flags still work:
<field name="create_date" readonly="1"/>
See also
- Views & menus — full view XML reference
- View types — per-view arch structure
- SWC widget catalog