コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
4397 ビュー

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.

アバター
破棄
著作者 最善の回答

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.

アバター
破棄
関連投稿 返信 ビュー 活動
0
11月 15
3056
0
3月 15
3988
0
2月 24
4580
0
11月 17
4091
1
3月 16
6691