O'Reilly logo

Odoo Development Cookbook by Daniel Reis, Alexandre Fayolle, Holger Brunn

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using client-side QWeb templates

Just as it's a bad pattern to programmatically create HTML code in controllers, you should create only the minimum amount of DOM elements in your client side JavaScript code. Fortunately, there's a templating engine available for the client side too and, even more fortunately, it's just the same as for server side code.

We'll use Qweb to make the module from the previous recipe, Create custom widgets, more modular by moving the DOM element creation to QWeb.

Getting ready

This recipe is just a modified version of the previous recipe, Create custom widgets, code, so grab a copy of it and use it to create the module ch15_r02.

How to do it...

We add the QWeb definition in the manifest and change the JavaScript code to use ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required