Se rendre au contenu
Menu
Cette question a été signalée
4 Réponses
6375 Vues

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
Ignorer

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

Auteur

nope, it doesn't work ;(

Auteur

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

Meilleure réponse

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
Ignorer
Auteur

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
Publications associées Réponses Vues Activité
0
mars 16
3346
0
déc. 15
4345
2
mars 15
4575
3
mars 15
28649
1
juin 23
2867