xml-tag-position (XML009)#

t-if, id or class attributes are not first in a tag.

What it does#

Checks the order of attributes in a tag: the conditions (t-if, t-else, t-elif) first, then the ids (id, t-att-id, t-attf-id), then the classes (class, t-att-class, t-attf-class). It applies when a tag has more than one of them, and to every <record>, <menuitem> and <template>.

Why is this bad?#

When the attributes that decide whether and what an element is come first, templates are easier to read and to review.

Example#

<div class="o_row" t-if="record.active">

Use instead:

<div t-if="record.active" class="o_row">

Fix safety#

Safe: the attributes are moved; values and layout are kept.

Opt-in#

ALL does not include this check, a matter of style that OCA’s CI does not run. Enable it with select = ["ALL", "XML009"].