跳至内容
菜单
此问题已终结
2 回复
6638 查看

I would like to know the way to hide the "edit" button from the form view when it is in a specific state

for example: In the help desk I have the stage_id, I want the edit button to be completely hidden from all people when it goes to "closed" state

形象
丢弃
最佳答案

Hi,

You can use JS to achieve this.

First you need to extend Form view.

var FormView = require('web.FormView');
var FormController = require('web.FormController');

Then using renderButtons function, you can find

renderButtons: function() {
this._super.apply(this, arguments);
if (this.$buttons) {
var button = this.$buttons.find('button.o_form_button_edit');
}
}

Now you have the button. Next, you need to check the condition and hide the button. For that

renderButtons: function() {
this._super.apply(this, arguments);
if (this.$buttons) {
if(this.initialSate.data.state == 'closed'){
this.$buttons.find('button.o_form_button_edit').hide();
}
}
}

Regards

形象
丢弃
相关帖文 回复 查看 活动
2
2月 23
1977
2
9月 15
5603
1
3月 15
3761
3
5月 24
3316
1
11月 22
3391