콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
3 답글
3739 화면
In a model's view, I have two buttons like these:

button name="button1" type="object" string="Button1"
button name="button2" type="object" string="Button2"

I want to hide Button2 once Button1 is clicked.
The user doesn't have write permission to that model. So, I can't use button's 'visible' property depending on a field, as the user wouldn't be able to change that field.

Odoo15
P.S. In the code above, I had to remove tag brackets because the forum engine didn't accept them!

아바타
취소
베스트 답변

Even if the user doesn't have the write permission for the model, you can use sudo() to write a boolean field as True and hide the second button.

아바타
취소
베스트 답변

Hello O.Salah,

you can define boolena field in the model and set attrs for button2.

Please find code in comment. 

I Hope this Will help you. 

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari 

아바타
취소

For Example:

custom_field = fields.Boolean('Custom Field')

def button1(self)
self.custom_field = True

<button name="button1" type="object" string="Button 1"/>
<button name="button2" type="object" string="Button 2" attrs="{'invisible': [('custom_field', '=', True)]}"/>

작성자 베스트 답변

Thanks Baiju kS,

This is exactly what I wanted

아바타
취소
관련 게시물 답글 화면 활동
1
6월 25
1775
3
7월 25
3378
1
5월 25
1528
1
5월 25
1783
4
5월 25
2917