Skip to content

[IMP] owl: help coding agents write Owl 3 code - #2079

Merged
ged-odoo merged 6 commits into
odoo:masterfrom
mcm-odoo:master-agent-reference-mcm
Nov 27, 2026
Merged

ged-odoo merged 6 commits into
odoo:masterfrom
mcm-odoo:master-agent-reference-mcm

Conversation

@mcm-odoo

@mcm-odoo mcm-odoo commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

AI coding agents learned Owl from Owl 2 code. In Owl 3 they keep writing Owl 2 code, which often fails silently, and they read the Owl source to find out why. This PR ships a reference for them with the build, makes the compiler reject directives it used to ignore silently, and fixes documentation that contradicts Owl 3.

Changes

Agent reference (packages/owl/owl.llm.md)

  • A condensed reference written for coding agents. It lists the Owl 2 habits that are wrong in Owl 3, the silent failures, and the full public API, and ends with a complete example.
  • The build copies it to dist/ and stamps it with the version. It is therefore published on npm, and the release script attaches it to the GitHub release, together with owl.d.ts.

Compiler: unknown directives throw

  • Before this PR, an unknown t-* attribute only threw on DOM elements. On <t> nodes and on t-call, t-call-slot, t-set-slot and t-set, it was ignored without any error.
  • The compiler now also throws for:
    • removed Owl 2 directives (t-raw, t-slot, t-portal), with an error that names the replacement;
    • a known directive that has no effect where it is used, for example t-on-* on <t>, t-key with t-call, or t-set with t-out;
    • a misspelled t-att*; for example, t-attclass used to render a lass attribute;
    • t-call-slot or t-call-block on an element other than <t>, which used to drop the element.

Compiler: t-esc throws

  • t-esc used to work and only logged a deprecation warning. It is now a removed directive like t-raw, and the error says to use t-out instead.

onWillUpdateProps deprecated

  • The hook is marked @deprecated and will be removed. The docs said it was already removed, but it is still exported.
  • To react to a prop, pass it as a signal and derive state from it with computed, useEffect or useOnChange.
  • A plain prop read inside a computed or an effect is currently tracked. That behavior is not part of the API and may change, so the docs no longer present it as a feature.

Documentation

  • Fixes examples that fail when run against the current build: the README example threw at mount, and the ErrorBoundary, SVG, slots, useOnChange and migration examples are also fixed.
  • Corrects statements that do not match Owl 3: t-set escaping, the iterables t-foreach accepts, the falsy values for which t-att omits the attribute, createRoot with async plugins, and the errors ErrorBoundary catches.
  • States two directions of Owl 3:
    • plugins are the architectural units, and components are their presentation;
    • props are declared with a schema; useProps() and useProps([...]) still exist, but the schema form is preferred.
  • Adds a section on schemas and types to the agent reference.

Impact on Odoo

With this branch, 9 templates of Odoo no longer compile. They must be fixed before the Owl upgrade lands in Odoo, or in the same change.

6 templates contain a directive that was silently ignored until now, so each one is an existing bug:

Module Template Problem
web list_renderer.xml t-valuef
spreadsheet o-spreadsheet-TopBar t-att-id on <t>
spreadsheet o-spreadsheet-ValidationMessages t-call-slot on <span>
appointment gantt_popover.xml t-inherit-mode without t-inherit
l10n_in_hr_payroll tax_declaration_client_action.xml t-foreach-index
sign sign_items.xml t-index

3 templates still use t-esc and must switch to t-out:

Module File
web webclient/clickbot/clickbot_overlay.xml
hr_expense_stripe components/stripe_attachment_widget.xml (2 occurrences)
hr_payroll js/version_update_dialog.xml

Odoo applies t-inherit before Owl compiles a template, so templates that use t-inherit are not affected. The two spreadsheet templates must be fixed in the o-spreadsheet repository.

Follow-up in Odoo

  • Copy owl.llm.md next to the vendored owl.js.
  • Add a line to AGENTS.md that points agents to owl.llm.md.

Testing

  • The core, compiler (with new parser tests), runtime and doc-link test suites pass. Prettier and eslint report no issues.
  • All README, documentation and reference examples run against the built bundle.

AI coding agents know Owl 2 from their training data, and write Owl 2
code that fails, often silently, in Owl 3. The Owl 3 documentation is
not at hand when they work: the npm package only contains the bundles,
and Odoo only vendors owl.js and owl.d.ts. So agents end up reading the
Owl source each time.

This commit adds owl.llm.md, a condensed reference written for them:
the Owl 2 habits that are wrong in Owl 3 (and what happens if they are
used anyway), the silent failures to avoid, the whole public API, and a
complete example. The build copies it to dist/, stamped with the
version, so it is published with the npm package, and the release
script attaches it to the GitHub release, next to the bundles.
Before this commit, an unknown directive (a t-* attribute that Owl does
not handle) only threw on DOM elements. On a <t> node, or as a
parameter of t-call, t-call-slot, t-set-slot or t-set, it was silently
ignored. In particular, the Owl 2 directives t-slot and t-raw rendered
nothing, and a directive meant for DOM elements (t-on-*, t-att-*, ...)
had no effect on a <t> node. On DOM elements too, any attribute starting
with "t-att" was accepted, so a misspelled t-attclass rendered a "lass"
attribute.

This commit makes the compiler throw in all these cases:
- an unknown directive throws, and the Owl 2 directives that no longer
  exist (t-raw, t-slot, t-portal) get an error telling what to use
  instead;
- a known directive used where it has no effect throws an error saying
  so: on a <t> node, together with a directive that ignores it (t-key
  with t-call, t-set with t-out, ...), or t-ref on a <t t-out>;
- t-call-slot and t-call-block, like t-call, only work on <t> nodes:
  on another element, the element was dropped.

The attributes of a t-set-slot node (scope, handlers) are still read
after its content is parsed, as a directive on the same node (t-call,
t-tag, t-component) may use them too, so they are not reported there.
An empty t-translation-context is now ignored, as no context.

Compiling the templates of Odoo with this change reveals 6 templates
with such an ignored directive (t-valuef, t-index, t-foreach-index,
t-inherit-mode without t-inherit, t-att-id on a <t>, and t-call-slot
on a <span>). They have to be fixed, as they now fail to compile.
onWillUpdateProps is deprecated and will be removed. The documentation
said it was already removed, while it is still exported: it now says it
is deprecated, and the hook is marked as such in the type declarations.

Its replacement is to give the props that a component reacts to as
signals, and to derive state from them with computed values, effects or
useOnChange. A plain prop is a value for the template. Reading a plain
prop in a computed value or an effect currently subscribes to it, but
this is not part of the API and may change: the documentation no longer
presents it as a feature, and its examples use signal props instead.
Running the examples of the documentation against the current build
showed several of them do not work, and some statements are wrong:

- the README example throws at mount: t-model is given a plain object
  property instead of a signal, and push is called on the signal
  instead of its value;
- ErrorBoundary does not catch errors thrown in event handlers, its
  example created an effect that outlives the component, and missed
  imports and a component registration;
- the body of a t-set is not escaped, t-foreach accepts any iterable,
  Sets included, and t-att-* only omits the attribute for false, null
  and undefined (0 and "" are set);
- the SVG and slots examples read props without `this.` and without
  useProps;
- the useOnChange example could show the record of a previous id when
  responses arrive out of order;
- the useMouse example of the migration guide gave no event name to
  useListener, and an example of the design notes used a useInterval
  hook that does not exist;
- a root created with app.createRoot must wait for the plugins with an
  asynchronous onWillStart, as the mount helper does.
Two orientations of Owl 3 were not stated by the documentation:

- plugins are the architectural units of an application: they own its
  state, data and logic, while components are the presentation of these
  units, with only UI state of their own. The plugins and components
  pages now say so, and the agent reference presents plugins first;
- a component declares its props with a schema. useProps also accepts a
  list of keys or no argument, but the schema documents, validates and
  types the props: the documentation now presents it as the preferred
  form, and its examples use it.

The agent reference also gets a section on schemas and types: the
validators, optional values and defaults, the types that are only
checked by TypeScript, and how to reuse and apply a schema.
t-esc was deprecated in favor of t-out: it still worked, and logged a
deprecation warning. It is now a removed directive, like t-raw, t-slot
and t-portal: using it throws an "Unknown QWeb directive" error telling
to use t-out instead.

3 templates of Odoo still use t-esc and have to be converted to t-out.
@mcm-odoo
mcm-odoo force-pushed the master-agent-reference-mcm branch from bbd3b15 to 7503e9a Compare November 26, 2026 14:16
odoo-mergebot Bot pushed a commit to odoo/o-spreadsheet that referenced this pull request Nov 27, 2026
PR odoo/owl#2079 in owl3 introduces a detection
of wrong owl3 usages. There was two instances in our code:
- t-att-id on a <t> tag does nothing
- t-call-slot on a <span>

This commit fixes those wrong usages in our code.

closes #10219

Task: 0
Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
@mcm-odoo
mcm-odoo marked this pull request as ready for review November 27, 2026 12:03
@ged-odoo
ged-odoo merged commit a058601 into odoo:master Nov 27, 2026
2 checks passed
odoo-mergebot Bot pushed a commit to odoo/o-spreadsheet that referenced this pull request Nov 27, 2026
PR odoo/owl#2079 in owl3 introduces a detection
of wrong owl3 usages. There was two instances in our code:
- t-att-id on a <t> tag does nothing
- t-call-slot on a <span>

This commit fixes those wrong usages in our code.

closes #10221

Task: 0
X-original-commit: 0511aaf
Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
Signed-off-by: Pierre Rousseau (pro) <pro@odoo.com>
odoo-mergebot Bot pushed a commit to odoo/o-spreadsheet that referenced this pull request Nov 27, 2026
PR odoo/owl#2079 in owl3 introduces a detection
of wrong owl3 usages. There was two instances in our code:
- t-att-id on a <t> tag does nothing
- t-call-slot on a <span>

This commit fixes those wrong usages in our code.

closes #10222

Task: 0
X-original-commit: 0511aaf
Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
Signed-off-by: Pierre Rousseau (pro) <pro@odoo.com>
odoo-mergebot Bot pushed a commit to odoo/o-spreadsheet that referenced this pull request Nov 27, 2026
PR odoo/owl#2079 in owl3 introduces a detection
of wrong owl3 usages. There was two instances in our code:
- t-att-id on a <t> tag does nothing
- t-call-slot on a <span>

This commit fixes those wrong usages in our code.

closes #10222

Task: 0
X-original-commit: 0511aaf
Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
Signed-off-by: Pierre Rousseau (pro) <pro@odoo.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants