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

Custom view based on res.partner subclass

Suscribirse

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

Se marcó esta pregunta
developmentviewsinheritancev17
2 Respuestas
2557 Vistas
Avatar
Mark Nuttall-Smith

I have 2 models that inherit from res.partner, using traditional class inheritance. Each subclass adds a few custom fields.

class PartnerExtA(models.Model):
_inherit = 'res.partner'
field_a = fields.Char()

class PartnerExtB(models.Model):
_inherit = 'res.partner'
field_b = fields.Char()

I need to customise the form view of each of these subclasses, and the make the customised view the default when the model is displayed.

For example, when displaying PartnerExtA, the res.partner form should look like:

name, phone, field_a   (and no other fields)

And when displaying PartnerExtB, the form should look like:

name, phone, field_b   (and no other fields)

I've tried playing with removing and adding fields using a pattern like this:
(I've removed the leading character from the xml tags as the forum was stripping the code otherwise :/ ) 

record>
field name="name">res.partner.view.form.inherit.exta
field name="model">res.partner
field name="inherit_id" ref="base.view_partner_form"/>
field name="arch" type="xml">
xpath expr="//group" position="attributes">
attribute name="invisible">1
/xpath>

xpath expr="//group" position="after">
group invisible="not field_a">
field name="name"/>
field name="phone"/>
field name="field_a"/>
/group>
/xpath>
/field>
/record>

But things get complicated with the views interacting in strange ways. 

Is there a better way to render a different view based on the concrete subclass in Odoo 17? Can I use the QWeb templating language somehow? 

Any thoughts on this gratefully received... 

0
Avatar
Descartar
Avatar
Dishant Mistry
Mejor respuesta

In Odoo, you can customize the form view for each subclass of a model by creating separate XML views tailored to the specific fields of each subclass. Instead of manipulating the view through complex XML modifications, you create distinct form views for each subclass, specifying only the relevant fields for that subclass.

To achieve this, you define separate XML files for each subclass and configure them to display the appropriate fields. Then, you create actions that reference these views, ensuring that when a user accesses a record of a specific subclass, the corresponding form view is displayed.

Feel free to reach out if you have any further questions or need additional assistance.

1
Avatar
Descartar
Mark Nuttall-Smith
Autor

Thanks for the reply Dishant. That's helpful. I guess this implies that I should be using Prototype inheritance rather than Class inheritance?

1. https://www.odoo.com/documentation/17.0/developer/tutorials/server_framework_101/12_inheritance.html#model-inheritance

Avatar
vision of king
Mejor respuesta

بنة ىىلالالخههخمنفققبي انبمر برنىثقلرمنقب ؤثنثيسنمثؤىبقثبهقخبلق ىىقثىم نرىقبنمث نبىقمنلىمق ىقثمنلقثر ثقبىقمن  

-1
Avatar
Descartar
Mark Nuttall-Smith
Autor

I'm sorry I don't speak Arabic. Google translate says this means: "the daughter of the people of the world", which doesn't seem very relevant!

¿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
Style Error: "Could not execute command 'sassc'
development v17
Avatar
Avatar
Avatar
Avatar
Avatar
7
dic 24
9592
View inheritance hiding a field
views inheritance
Avatar
Avatar
1
nov 24
2588
classical inheritance
development inheritance
Avatar
Avatar
1
oct 24
2482
Customizing the save manually button Resuelto
inheritance v17
Avatar
Avatar
Avatar
2
oct 24
3457
Xpath no odoo v17
development v17
Avatar
0
jul 24
1642
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.

Website made with

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