Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Is there a non-hack way to add my own QWeb directives?

By
Konstantinos Metaxas
on 10/10/15, 3:23 AM 248 views

I come from a Django background and an app can register template directives and they are available to all other apps (there is a central registry basically).  Is there a way for my app to register a  new Qweb directive/tag?

For example i may want to create something like: <t thumbnail="{'image':o.image,'format':'90x90 bw'}/>

So, is there a way to hook up extra directives  to QWeb?

0
Konstantinos Metaxas
On 10/12/15, 2:00 PM

I'm answering my own question here but the solution is not that hard.

You can take a look at   https://github.com/OCA/server-tools/tree/8.0/qweb_usertime which does exactly that.

Basically override QWeb model like you would any model, and define your own render_tag_<tagname>() method.  

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 10/10/15, 3:23 AM
Seen: 248 times
Last updated: 10/12/15, 2:00 PM