Skip to Content
Menu
This question has been flagged
4 Replies
5452 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 ;)



Avatar
Discard

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

Author

nope, it doesn't work ;(

Author

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

Best Answer

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


Avatar
Discard
Author

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 ?

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
Related Posts Replies Views Activity
0
Mar 16
2318
0
Dec 15
2941
2
Mar 15
3463
3
Mar 15
26668
1
Jun 23
1766