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

how to Customize User Name display  on upper right corner in Odoo 16 using custom addons or studio . The idea is to display the role of the user like Manager , Billing etc

อวตาร
ละทิ้ง

the question if there are 10 roles for a user, than which role you want to display?

ผู้เขียน

we may have preference for the role , in my case user will only have one role

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

Thanks . Where should i load this file in custom module

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

Hi Shibi, 


You can try below solution:


  •  Add a role field with many2one/selection type on user or on partner level.
  • Change the display name on the right corner with xpath in the rendering template.


Thanks.


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

I tried the xpath solution seems to be not working . Not sure if understand this "Add a role field with many2one/selection type on user or on partner level."

Hi Shibi,

Let me help you with the xpath:

<template id="show_email_on_login" inherit_id="portal.user_dropdown">
<xpath expr="//span[@t-if='_user_name']" position="replace">
<span t-if="_user_name" t-attf-class="#{_user_name_class}" t-esc="user_id.email[:23] + '...' if user_id.email and len(user_id.email) &gt; 25 else user_id.email"/>
</xpath>
</template>

With this xpath, I am able to show email instead of the Customer name, similarly you can relace your field on above xpath with email to show ROLE .
Thanks

Thanks.

Related Posts ตอบกลับ มุมมอง กิจกรรม
filling a field with the current user แก้ไขแล้ว
2
มิ.ย. 22
3744
1
ก.ย. 19
6164
1
เม.ย. 17
5544
3
มี.ค. 15
11328
1
มี.ค. 15
3598