Ir al contenido
Menú
Se marcó esta pregunta
4 Respuestas
6352 Vistas

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
Descartar

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

Autor

nope, it doesn't work ;(

Autor

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

Mejor respuesta

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
Descartar
Autor

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
Publicaciones relacionadas Respuestas Vistas Actividad
0
mar 16
3328
0
dic 15
4339
2
mar 15
4532
3
mar 15
28616
1
jun 23
2837