Skip to Content
Menu
This question has been flagged
1 Reply
3651 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.

Avatar
Discard
Author Best Answer

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.

SOLUTION:


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

Greetings.

Avatar
Discard
Related Posts Replies Views Activity
0
Nov 15
2478
0
Mar 15
3161
0
Feb 24
3697
0
Nov 17
3442
1
Mar 16
5796