تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
3 الردود
5132 أدوات العرض

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.

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
1
مارس 25
1291
0
مارس 25
1268
0
يناير 25
3324
0
أكتوبر 24
1297
1
أغسطس 23
14627