Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
3 ตอบกลับ
5262 มุมมอง

Hello,


I have extended the hr.employee model by some fields and also extended the hr.employee.form view by one notebook page showing some user dependent sensible data. 

But this data should only be shown if the employee/user currently logged in selected his own record. If he selects the records of another employee I want the notebook page not to be shown to this user.


How can I achieve this?


Thanks for any help in advance!! 

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hello

You can achieve this using attrs.

You need to apply attrs on your new page like : attrs="{'invisible':[('user_id','!=',context.get('uid'))]}".

user_id is Related User field of hr.employee.

For Ex:

<page string="New Page" attrs="{'invisible':[('user_id','!=',context.get('uid'))]}">

<!-- Page content -->

</page>

อวตาร
ละทิ้ง
ผู้เขียน

Hi, unfortunately I get this error when applying your suggestion: AttributeError: Element '' cannot be located in parent view

ผู้เขียน

After I put the expression in the right place it worked!!! Many thanks!

คำตอบที่ดีที่สุด

Hi Major, just use domain attribute at related action of menu.

like this

<field name="domain">['partner_id', '=', uid]</field>


here uid is current User ID.

here i take  partner_id as example, just give whatever you want compare with current user id.

อวตาร
ละทิ้ง
ผู้เขียน

Does this also fit to a inherited view? Especially a notebook page?

ผู้เขียน คำตอบที่ดีที่สุด

Hi thanks to all for the answers! I will try them and report if it worked for me.

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
มี.ค. 25
1492
0
มี.ค. 25
1442
0
ม.ค. 25
3573
0
ส.ค. 25
1469
1
ส.ค. 23
14925