Odoo Help


How to change template of instance.web.ViewManager according to dataset.context parameter?

Daniela Scarpa
on 8/6/15, 10:38 AM 1,060 views

I want to create a special custom view for kanban. This view has to have special View Manager too.
In my_module_view.xml file I have menuitem and action definition. Action has context: 

<field name="context">{'special_view': True}</field>

Into my_module.js file I want to change template of instance.web.ViewManager only when context has 'special_view' true.

init: function (parent, dataset, view_id, options) {
    if (this.dataset.context.special_view) {
    	this.template = "MyViewManager";
    this._super(parent, dataset, view_id, options);
Unfortunately, this.dataset is null and I get this exception: Uncaught TypeError: Cannot read property 'context' of undefined.

Is there another way to change this template according to special_view value of context?

Thank you.

Daniela Scarpa
On 8/6/15, 12:38 PM

Because I've found a solution myself, I want to answer my own question, in case someone will have the same problem.

The code was right, but I was customizing the wrong Class.


    init: function (parent, dataset, view_id, options) { this._super(parent, dataset, view_id, options); if (this.dataset.context.special_view) {     this.template = "MyViewManager"; } },


About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 8/6/15, 10:38 AM
Seen: 1060 times
Last updated: 3/7/16, 5:50 AM