Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How to hide field depending on the username ?

By
Dr Obx
on 12/23/15, 6:08 AM 601 views

Is it possible If yes, how should it do it ?

I would like to hide a button but it should be visible only for one user with very specific id or login/name.

I tried to use user_id but it gives me an error: Uncaught Error: Unknown field user_id in domain [["user_id","!=","Wario"]]

and I can't add user_id because is not available in stock module ;)

http://...../web/static/src/js/view_form.js:1697

Already checked this post:

https://www.odoo.com/forum/help-1/question/conditionally-display-or-hide-a-field-in-a-view-13042

Help a bit but not as much as I need ;)



hi, to get the id of your current user you can use "self._uid" I think.

Guillaume Seran
on 12/23/15, 8:46 AM

nope, it doesn't work ;(

Dr Obx
on 12/23/15, 5:37 PM

Why everything is so complicated in Odoo ..... :)

Dr Obx
on 12/23/15, 5:38 PM
1

Tarek Mohamed Ibrahim

--Tarek Mohamed Ibrahim--
896
| 5 3 7
Gîza, Egypt
--Tarek Mohamed Ibrahim--

I am an old VFP developer on ERP

I have moved to 2p since Nov-2014 and started developing with Python on Odoo.

https://www.linkedin.com/profile/public-profile-settings?trk=prof-edit-edit-public_profile

tibrahim@2p.com.sa

Tarek Mohamed Ibrahim
On 12/30/15, 5:28 AM

standard solution is to create a group and make this field seen only by this group, and adding to this group only the desired user.


Another way is to create a function field in the model of the view. By default the function field has 'uid' as one of the parameters passed to it. Compare the value of 'uid' with the specific id you need to check with and return true if it is the desired id.

the following will be the function body

res = {}
for i in ids:
     res[id] = True if uid==id else False
return res


Hi Tarek, I did created a group in Odoo (Settings/Groups/Create) and added Superuser then in xml added groups="stock.group_stock_superuser" what technically should hide selected field andmake it wisible only for users in this group. Is it right ? or am I wrong ?

Dr Obx
on 1/4/16, 5:13 AM
Hi Dr Obx,

This exactly will show the field tagged with superuser group to the superuser only and hide it from others, you have to upgrade the module and check the view

On Mon, Jan 4, 2016 at 1:13 PM, Dr Obx <robert.amberwitch@gmail.com> wrote:

Hi Tarek, I did created a group in Odoo (Settings/Groups/Create) and added Superuser then in xml added groups="stock.group_stock_superuser" what technically should hide selected field andmake it wisible only for users in this group. Is it right ? or am I wrong ?

Regards

Robert A.Lien



--
Tarek Ibrahim
ERP Developer
Cairo Branch
Tarek Mohamed Ibrahim
on 1/5/16, 8:59 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 12/23/15, 6:08 AM
Seen: 601 times
Last updated: 12/30/15, 7:32 AM