Ir al contenido
Odoo Menú
  • Iniciar sesión
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • PdV para tiendas
    • PdV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en vivo
    • eLearning
    Cadena de suministro
    • Inventario
    • Manufactura
    • PLM
    • Compras
    • Mantenimiento
    • Calidad
    Recursos humanos
    • Empleados
    • Reclutamiento
    • Vacaciones
    • Evaluaciones
    • Referencias
    • Flotilla
    Marketing
    • Redes sociales
    • Marketing por correo
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyectos
    • Registro de horas
    • Servicio externo
    • Soporte al cliente
    • Planeación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Artículos
    • WhatsApp
    Aplicaciones externas Studio de Odoo Plataforma de Odoo en la nube
  • Industrias
    Venta minorista
    • Librería
    • Tienda de ropa
    • Mueblería
    • Tienda de abarrotes
    • Ferretería
    • Juguetería
    Alimentos y hospitalidad
    • Bar y pub
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidora de bebidas
    • Hotel
    Bienes inmuebles
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión de bienes inmuebles
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Firma contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Manufactura
    • Textil
    • Metal
    • Muebles
    • Comida
    • Cervecería
    • Regalos corporativos
    Salud y ejercicio
    • Club deportivo
    • Óptica
    • Gimnasio
    • Especialistas en bienestar
    • Farmacia
    • Peluquería
    Trades
    • Personal de mantenimiento
    • Hardware y soporte de TI
    • Sistemas de energía solar
    • Zapateros y fabricantes de calzado
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin fines de lucro
    • Agencia para la protección del medio ambiente
    • Alquiler de anuncios publicitarios
    • Fotografía
    • Alquiler de bicicletas
    • Distribuidor de software
    Descubre todas las industrias
  • Odoo Community
    Aprende
    • Tutoriales
    • Documentación
    • Certificaciones
    • Capacitación
    • Blog
    • Podcast
    Fortalece la educación
    • Programa educativo
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtén el software
    • Descargar
    • Compara ediciones
    • Versiones
    Colabora
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Conviértete en partner
    • Servicios para partners
    • Registra tu firma contable
    Obtén servicios
    • Encuentra un partner
    • Encuentra un contador
    • Contacta a un consultor
    • Servicios de implementación
    • Referencias de clientes
    • Soporte
    • Actualizaciones
    GitHub YouTube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicita una demostración
  • Precios
  • Ayuda

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Contabilidad
  • Inventario
  • PoS
  • Proyectos
  • MRP
All apps
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Ayuda

How to apply attrs based on assigned groups to logged in user?

Suscribirse

Reciba una notificación cuando haya actividad en esta publicación

Se marcó esta pregunta
attrsgroupsruntimeodooV8
2 Respuestas
17587 Vistas
Avatar
Anil Kesariya

Hello everybody,

My Goal is to make field readonly based on assigned group to logged in user.

I want to make few field readonly based on assgined groups to logged in user.

I have tried these two methods to set attrs for perticular field.

For Eg, I want to make readonly field on SO form.

We have user_id field inside SO, so i have applied like this on xml part.

This doesn't  work!

<field name="field name" position="attributes">

<attribute name="attrs">{'readonly':[('group_name','in',[group.id for group in user_id.groups_id])]}</attribute>

</field>

This is too does not work!

<field name="field name" position="attributes">-->

<attribute name="attrs">{'readonly':[('group_name','in',[group.id for group in user.groups_id])]}</attribute>

</field>

Even we have user_id field inside the model, its give user_id field is not defiend. how?

I have tried to apply the same thing based on_change method too!

Is it possible to set attrs on field using onchange method?

Anyboday has idea about this?

Thanks in advance!

Regards,

Anil.

2
Avatar
Descartar
Sehrish

Yes you can apply attributes [visible/invisible, readonly] based on different users. The idea is to create a Boolean field and make this field True/False on onchange of some field, and later use that boolean field in attr.

Have a look into code: http://learnopenerp.blogspot.com/2016/10/how-to-visible-and-invisible-fields-in.html

Hope its helpful for you and others.

Thanks

Avatar
Anil Kesariya
Autor Mejor respuesta

Hi All,

I found solution to achive this goal.

Created boolean field on backend which set true based on parnter onchange method.

That onchange method will search that current logged in user is belongs to that specific group than it will return true for that boolean.

Based on boolean value i have applied attrs on field to make it readonly.

Thanks!




3
Avatar
Descartar
Avatar
Atchuthan - Technical Consultant, Sodexis Inc
Mejor respuesta

You could inherit your FORM view with a particular group access to modify readonly attribute.

Please check the sample code available here 


NOTE:

To add your group:
<field name="groups_id" eval="[(4, ref('MODULE_NAME.GROUP_EXTERNAL_ID'))]"/>

To replace other groups and add your group only: <field name="groups_id" eval="[(6,0,[ref('MODULE_NAME.GROUP_EXTERNAL_ID')])]" />


4
Avatar
Descartar
Anil Kesariya
Autor

Thanks for this ans. but this will only set perticuler group to field right? or it will make it readonly that field rest of groups those are not assigned to that field?

¿Le interesa esta conversación? ¡Participe en ella!

Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.

Registrarse
Publicaciones relacionadas Respuestas Vistas Actividad
Multiple attrs in form Resuelto
attrs odooV8
Avatar
Avatar
3
ene 24
14431
How to make many2one field readonly for user which is under specific group?
security attrs readonly groups
Avatar
Avatar
Avatar
Avatar
3
dic 21
16945
How to fix a group and show related user in drop down ??
groups python2.7 openerp odooV8
Avatar
0
jul 19
497
Dyanamic required field based on company. Resuelto
attrs onchange required odooV8
Avatar
Avatar
Avatar
2
ago 17
5412
ODOO Use invisible attrs on field | Condition: If the number is 0.0
attrs xml invisible odooV8
Avatar
Avatar
1
sept 16
11772
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento en Odoo.sh
  • Soporte
  • Actualizaciones del software
  • Desarrollos personalizados
  • Educación
  • Encuentra un contador
  • Encuentra un partner
  • Conviértete en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contáctanos
  • Empleos
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Legal • Privacidad
  • Seguridad
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo es un conjunto de aplicaciones de código abierto que cubren todas las necesidades de tu empresa: CRM, comercio electrónico, contabilidad, inventario, punto de venta, gestión de proyectos, etc.

La propuesta única de valor de Odoo es ser muy fácil de usar y estar totalmente integrado.

Sitio web hecho con

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now