Skip to Content
Menu
This question has been flagged

Hi, I need your help.

I want to make the confirm button invisible. (v13)

https://prnt.sc/un4jqw


object: purchase order

user_id -> id=1=user1, id=2=user2

 

P0001 -> user_id=user1

P0002 -> user_id=user2

 

Login user=user1

P0001 -> user_id=user.id -> BUTTON -> confirm_order -> invisible=1

P0002 -> user_id != user.id -> BUTTON -> confirm_order -> invisible=0



  <xpath expr="//form[1]/header[1]/button[@name='button_confirm'][2]" position="attributes">

                <attribute name="attrs">{"invisible": [["user_id","=","user.id"]]}</attribute>

  </xpath>

 

Thank you.

Best regards.

Tugay HATIL

Avatar
Discard
Best Answer

you have to get login user_id in form view so define not store compute field on the model and use it in attrs

login_user_id = fields.integer('_compute_login_user')
def _compute_login_user(self)
       self.login_user_id = self.env.user.id

in xml

<xpath expr="//form[1]/header[1]/button[@name='button_confirm'][2]" position="attributes">
                <attribute name="attrs">{"invisible": [["user_id","=","login_user_id"]]}</attribute>
</xpath>

<xpath expr="//field[@name='name']" position="after">
           <field name="login_user_id" invisible="1"/>
<xpath>

Avatar
Discard
Related Posts Replies Views Activity
0
May 22
1194
0
Jul 24
864
1
Nov 20
2701
1
Oct 20
3120
3
Apr 18
6154