owl-foreach-without-key (OWL001)#

A t-foreach in an OWL template has no t-key.

Applies to Odoo 16.0 and later.

What it does#

Reports elements with t-foreach and no t-key in the OWL templates of the module’s assets.

Why is this bad?#

OWL 2 refuses to compile the template: “Directive t-foreach should always be used with a t-key!”. The component fails where it renders, in the browser only. Server-side QWeb (views, reports, website templates) does not need t-key and is not checked.

Fix safety#

Unsafe: adds t-key="<t-as>_index", which compiles but keys by position. A unique value of the items (line.id) lets OWL keep their state when the list changes.