Skip to Content

How to write your website's custom JavaScript with Interactions

Duration: 23:57


PART 1 — Analytical Summary 🚀

Context 💼

In this 24‑minute session, Robin from Odoo’s Website Builder R&D team introduces Interactions, a modern replacement for Odoo’s legacy public widgets, shipping in Odoo 19. The talk demonstrates how developers can write custom JavaScript for website snippets using an ES6 class pattern, a lightweight runtime called Calibri (a “hummingbird”), and a lifecycle that mirrors Owl 2. The goal: modernize website front-end development, reduce jQuery usage, streamline patterns across Odoo, and make edit mode behavior predictable and safe.

Core ideas & innovations ⚙️

At the heart of Interactions is an extendable base class with a simple lifecycle: setup, willStart (async), start, and destroy. Developers should avoid constructors, use setup for pre-start DOM data, and place async calls (e.g., API fetches) in willStart. Crucially, event listeners are now attached at start, eliminating race conditions common with earlier patterns. Built-in helpers handle routine concerns automatically: for example, registering an event through class helpers ensures it’s removed during destruction without manual cleanup.

Dynamic UI updates are authored through a dynamicContent property that declaratively maps selectors to directives: t-out for text, t-att for attributes, t-class and t-style (object-returning) for styling, t-on for event binding (with modifiers like .prevent, .stop, .capture, .once, .noUpdate, and .withTarget), and t-component to mount an Owl component inline. For elements outside the root node, dynamicSelectors exposes shortcuts such as _body, _document, _window, and _root.

Interaction instances are discovered by a CSS selector; no template is required for the JavaScript itself. For the Website Builder, however, the snippet’s HTML still comes from an XML template. Interactions must be registered in the public interactions registry, and to function within the Builder’s edit mode, also in the public interactions edit registry. Because edit mode routinely destroys and restarts interactions, the framework provides waitFor to guard async work—if an interaction is destroyed before a promise resolves, the awaited work is safely canceled. For edit mode customization, a recommended approach is an edit-mode mixin that overrides behavior (e.g., removing side-effectful event bindings), preserving extensibility when other modules extend the public interaction.

A demo “weather” snippet illustrates it all: input-driven city changes trigger API calls, dynamic content updates, and edit-mode-safe behavior that avoids triggering fetches while a user designs the page.

Impact & takeaways 🧠💬

Interactions bring a coherent, modern JavaScript model to Odoo’s web layer. Developers gain:

  • Consistency with Owl syntax and lifecycle, plus ES6 classes and minimized jQuery.
  • Safer async code via willStart and waitFor, and fewer leaks thanks to auto-cleaned listeners.
  • Declarative UI updates through dynamicContent and dynamicSelectors, with predictable re-renders after handlers.
  • First-class edit mode integration by dual registry registration and optional mixins to disable side effects while editing.
  • Straightforward migration from public widgets, with documentation focused on the migration path and testing support via Hoot unit tests.

Practical clarifications: a CSS selector is enough to initialize an interaction; the XML template is only for snippet HTML. In public browsing, destruction typically occurs on navigation; in edit mode, it’s frequent during option changes—another reason the built-ins matter. On SEO, it’s standard JavaScript: use it thoughtfully, but modern search engines accommodate JS-heavy pages.

Net effect: custom website behavior in Odoo 19 becomes more maintainable, more predictable, and better aligned with the rest of the Odoo stack—while keeping the door open to gradually decouple from Owl over time. ⚙️

PART 2 — Viewpoint: Odoo Perspective

Disclaimer: AI-generated creative perspective inspired by Odoo's vision.

We’ve always believed that simplicity and integration compound value. With Interactions, we’re extending that principle to website development: one mental model, one lifecycle, and a consistent way to build UI—whether you’re writing a tiny snippet or a more sophisticated feature.

What excites me most is how this bridges the community. Teams familiar with Owl will feel at home. Newcomers can build safely with modern JavaScript, without juggling patterns across modules. And because Interactions are lightweight, testable, and edit‑mode aware, partners can ship cleaner solutions faster—exactly the kind of pragmatic elegance we aim for.

PART 3 — Viewpoint: Competitors (SAP / Microsoft / Others)

Disclaimer: AI-generated fictional commentary. Not an official corporate statement.

Odoo’s Interactions are a developer-experience win: ES6 classes, declarative updates, event modifiers, and lifecycle safety are all modern and sensible. The edit-mode story—and especially automatic cleanup and async guards—addresses common front-end pitfalls. For SMB and midmarket teams seeking agility, this is compelling.

At enterprise scale, Odoo will need to keep proving depth in governance, accessibility, and compliance (e.g., SOX, GxP), as well as long-term versioning and migration guarantees. The partial dependency on Owl is a strategic consideration; decoupling without breaking apps requires discipline. UX differentiation is strong here, but organizations will still compare this approach with established platforms (e.g., SAP UI5, Microsoft’s Power Platform) for role-based controls, auditability, and multi-cloud operability. The direction is solid—execution over several releases will determine how far it penetrates regulated and large-scale deployments.

Disclaimer: This article contains AI-generated summaries and fictionalized commentaries for illustrative purposes. Viewpoints labeled as "Odoo Perspective" or "Competitors" are simulated and do not represent any real statements or positions. All product names and trademarks belong to their respective owners.

Share this post
Archive
Sign in to leave a comment
How Odoo transformed the music entrepreneur's daily life of Théo Renier, winner of The Voice Belgium