Introduction


QWeb is the template engine used by the OpenERP Web Client. It is an XML-based templating language, similar to Genshi, Thymeleaf or Facelets with a few peculiarities:
  • It's implemented fully in javascript and rendered in the browser.
  • Each template file (XML files) contains multiple templates, where template engine usually have a 1:1 mapping between template files and templates.
  • It has special support in OpenERP Web's Widget, though it can be used outside of OpenERP Web (and it's possible to use Widget without relying on the QWeb integration).
The rationale behind using QWeb instead of a more popular template syntax is that its extension mechanism is very similar to the openerp view inheritance mechanism. Like openerp views a QWeb template is an xml tree and therefore xpath or dom manipulations are easy to performs on it.

Creating First Hello World using qweb


There are only two steps to create a custom web ui using qweb
  • create the openerp view in xml
  • create the js file that will print the html hello world on start

myweb_view.xml

UI.png

Field name
Description
tag
Id that will be link to javascript
After creating myweb_view.xml, the new view need to be added into the openerp.py. Please refer to http://openerp-7-by-bifrost.wikispaces.com/create+your+first+view

Create simple javascript

  • Create a new js file (static/src/js/first_module.js)
  • Insert the following syntax into js file
js.png
  • added the first_module.js into _ _openerp_ _.py
    • 'js':['static/src/js/*.js'],