Axelor Doc

Record action

This type of action is capable of setting default values or modify the contents of a field.

The syntax is:

<action-record
    name="actionName"
    model="actionModel"
    copy="true|false"
    ref="actionRef"
    search="actionSearch"
>
    <field ... [1..*]/>
</action-record>
  1. name : Name of the action
  2. model : Model of the action
  3. copy : Optional. False by default. Create referenced instead of its reference copy of the registration sought /.
  4. ref : Optional. Reference to the existing record from the context. This attribute overrides the attribute search if used.
  5. search : Optional. Search a record.
  6. field : Assigning values to the fields of context.

Example :

<action-record name="default-orderline-record" entity="com.axelor.sale.db.OrderLine">
    <field name="product" expr="action:default-product-record"/>
    <field name="price" expr="eval: (100.0 + someField)/anotherField" if="someField != null && anotherField > 0"/>
    <field name="quantity" expr="1"/>
    <field name="taxes" expr="action:default-tax-record"/>
</action-record>

or

<action-record name="default-tax-record" entity="com.axelor.sale.db.Tax"
    search="('self.code LIKE ?1', 'VAT%')">
    <field name="code" expr="VAT12"/>
    <field name="name" expr="Vat 12%"/>
    <field name="rate" expr="0.12"/>
</action-record>

A record action contains an expression for each field and possibly a test with the attribute if .

The second example is a special case. The attribute search search an existing record. If there is then the action is executed, otherwise, a new record is created.