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

Inherit a line in Qweb view to add groups="user.group"

Suscribirse

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

Se marcó esta pregunta
QwebInherit
1 Responder
104 Vistas
Avatar
Anton

How can I inherit these views to add groups="base.group_portal,base.group_user"?


0
Avatar
Descartar
Codesphere Tech

Hello,
Can you tell the exact place where you want to add groups?

Anton
Autor

@Codesphere Tech

The highlighted.

<t t-set="product_variant_id" t-value="product._get_first_possible_variant_id()"/>
and
<form t-if="product._is_add_to_cart_possible()">

Codesphere Tech

Hello
<xpath expr="//form[@t-if='product._is_add_to_cart_possible()']" position="attributes">
<attribute name="groups">base.group_portal,base.group_user</attribute>
</xpath>

Hope it helps to you.
I didn't find second view in Odoo 18..
Thanks.

Avatar
Cybrosys Techno Solutions Pvt.Ltd
Mejor respuesta
Hi,

To inherit a Qweb view in Odoo and add a groups attribute to a specific element, you need to create a custom module with an XML file. This XML file will contain an ir.ui.view record that inherits from the target Qweb template, such as website_sale.product. The inheritance is defined using the inherit_id attribute, pointing to the external ID of the original view.

Within this inheritance template, an xpath expression is used to precisely locate the HTML element you wish to modify. The position="attributes" directive is crucial here, as it tells Odoo to modify the attributes of the found element rather than its content. Subsequently, an <attribute name="groups"> tag is used to assign the desired group IDs (e.g., base.group_portal,base.group_user) to the element, thereby controlling its visibility based on user access rights.

Sample code:

<odoo>
    <data>
        <template id="my_custom_product_qweb_inherit" inherit_id="website_sale.product" name="Product Page Qweb Inheritance - Add Groups">
            <xpath expr="//div[hasclass('oe_product_price')]" position="attributes">
                <attribute name="groups">base.group_portal,base.group_user</attribute>
            </xpath>

            <!-- If you want to target a specific element by ID, for instance: -->
            <!-- <xpath expr="//div[@id='product_description_short']" position="attributes">
                <attribute name="groups">base.group_portal,base.group_user</attribute>
            </xpath> -->

            <!-- If you want to add a new element with groups, you would use 'after' or 'before' position and define the new element -->
            <!-- <xpath expr="//div[hasclass('oe_product_price')]" position="after">
                <div groups="base.group_portal,base.group_user">
                    <p>This content is only visible to portal and internal users.</p>
                </div>
            </xpath> -->
        </template>
    </data>
</odoo>
Finally, ensure your custom module's __manifest__.py file includes this new XML file in its data list and that the module depends on website_sale. After these changes, upgrading your custom module in Odoo will apply the inheritance, making the specified element visible only to users belonging to the defined groups.


Hope it helps

0
Avatar
Descartar
¿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
Qweb report not printing in Go4Hosting server
Qweb
Avatar
Avatar
Avatar
2
mar 16
4326
JSON code displayed instead of table
report Qweb
Avatar
Avatar
1
ago 23
2509
Border-image in qweb-pdf Odoo 13
qweb-css Qweb
Avatar
Avatar
1
mar 24
5723
How to use hover in the menu drop down list in website using qweb? Resuelto
Qweb hover
Avatar
Avatar
1
sept 21
10891
How to show or call a record list from another module for dropdown view in website page portal.
Qweb Odoo13.0
Avatar
0
abr 20
4363
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