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 inherit list (tree) view?

Suscribirse

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

Se marcó esta pregunta
treeviewinherit
3 Respuestas
16018 Vistas
Avatar
Ingbert Jüdt
I've got two models: Person, and Witness, which inherits from Person:

class Person(models.Model):
_name = 'ufodata.person'

first_name = fields.Char()
middle_name = fields.Char()
surname = fields.Char()
age = fields.Integer()
birthday = fields.Date()
obit = fields.Date()
gender = fields.Selection([
('male', 'Male'),
('female', 'Female'),
('other', 'Other')
], default="male", tracking=True)
addresses = fields.One2many('ufodata.address', 'resident', string='Addresses')

def name_get(self):
result = []
for record in self:
result.append((record.id, "%s %s %s" % (record.first_name, record.middle_name, record.surname)))
return result

class Witness(models.Model):
_name = 'ufodata.witness'
_inherit = {'ufodata.person'}
_rec_name = 'code_name'

code_name = fields.Char()
sightings = fields.Many2many('ufodata.sighting', 'sighting_witness_rel', string="Sightings")

I've got also two list views (I'll omit the form views, as inheriting them works fine):

<odoo>
<record id="view_tree_person" model="ir.ui.view">
<field name="name">Person List</field>
<field name="model">ufodata.person</field>
<field name="arch" type="xml">
<tree decoration-bf="first_name"
decoration-info="surname">
<field name="first_name" />
<field name="middle_name" />
<field name="surname" />
<field name="age" />
<field name="birthday" />
<field name="obit" />
<field name="gender" />
<field name="addresses" widget="many2many_tags" />
</tree>
</field>
</record>
</odoo>

<odoo>
<record id="view_tree_witness" model="ir.ui.view">
<field name="name">Witness List</field>
<field name="model">ufodata.witness</field>
<field name="inherit_id" ref="ufodata_app.view_tree_person" />
<field name="arch" type="xml">
<tree>
<field name="code_name" />
<field name="sightings" widget="many2many_tags" />
</tree>
</field>
</record>
</odoo>

Now inheriting the list view is NOT working.
(1) view_tree_witness will always show the "code_name" field in a column and nothing else.
(2) If I omit the "inherit_id" field entirely, inheritage will be assumed from the model and "code_name" is not found, producing an error
(3) The many2many field "sightings" is never shown
(4) If I add fields from the base view within the <tree> tag, they do not show up
<tree>
<field name="code_name" />
<field name="sightings" widget="many2many_tags" /> # not showing
<field name="first_name" /> # not showing
</tree>

To make it clear: none of these problems occur in form view, they are a tree view matter only. If I don't break the code entirely, I always
will have only one column in my view showing the code_name.

1
Avatar
Descartar
Sehrish

Inheritance in models and views: https://goo.gl/4Zyc9d

Ingbert Jüdt
Autor

Thanks, but I'm already working with two of the three odoo books from packt, and if they tell what to do in my case, they hide it well.

Avatar
Zbik
Mejor respuesta

Examples, first example add fields, next replace full tree:

<odoo>
<record id="view_tree_witness" model="ir.ui.view">
<field name="name">Witness List</field>
<field name="model">ufodata.witness</field>
<field name="inherit_id" ref="ufodata_app.view_tree_person" />
<field name="arch" type="xml">
<field name="addresses" position="after">
<field name="code_name" />
<field name="sightings" widget="many2many_tags" />
</field>
</field>
</record>
</odoo>


<odoo>
<record id="view_tree_witness" model="ir.ui.view">
<field name="name">Witness List</field>
<field name="model">ufodata.witness</field>
<field name="inherit_id" ref="ufodata_app.view_tree_person" />
<field name="arch" type="xml">
<tree position="replace">
<tree>
                <field name="code_name" />
<field name="sightings" widget="many2many_tags" />
<field name="first_name" />
                </tree>
           </tree>
</field>
</record>
</odoo>
PS. Probably you have problem with name field in sightings. How is defined ufodata.sighting?


2
Avatar
Descartar
Ingbert Jüdt
Autor

Currently, I have a problem with updating my views ... as if the -u parameter of the odoo-bin cmd line would not work - have to deal with that problem first.

Ingbert Jüdt
Autor

I tried out both variants, but unfortunately neither makes a difference. The ONLY field that is shown in the tree view is "code_name", "sightings" is ignored, and also none of the base model/view fields shows up. Still have no idea what the problem could be.

Ingbert Jüdt
Autor

As for "sightings", model and view are defined as follows:

class Sighting(models.Model):

_name = 'ufodata.sighting'

_rec_name = 'identifier'

identifier = fields.Char()

description = fields.Text()

begin = fields.Datetime()

end = fields.Datetime()

location = fields.Char()

case = fields.Many2one('ufodata.case', string='Case')

investigator = fields.Many2one('ufodata.investigator', string='Investigator')

comments = fields.One2many('ufodata.sightingcomment', 'sighting', string='Comments')

witnesses = fields.Many2many('ufodata.witness', 'sighting_witness_rel', string="Witnesses")

<odoo>

<!-- FORM -->

<record id="view_form_sighting" model="ir.ui.view">

<field name="name">Sichtungen</field>

<field name="model">ufodata.sighting</field>

<field name="arch" type="xml">

<form string="Sightings">

<sheet>

<group>

<field name="identifier" />

<field name="description" />

<field name="begin" />

<field name="end" />

<field name="location" />

<field name="case" widget="many2one_tags" />

<field name="investigator" widget="many2one_tags" />

<field name="comments" widget="one2many_tags" />

<field name="witnesses" widget="many2many_tags" />

</group>

</sheet>

</form>

</field>

</record>

<!-- LIST -->

<record id="view_tree_sighting" model="ir.ui.view">

<field name="name">Sightings List</field>

<field name="model">ufodata.sighting</field>

<field name="arch" type="xml">

<tree decoration-bf="identifier">

<field name="identifier" />

<field name="description" />

<field name="begin" />

<field name="end" />

<field name="location" />

<field name="case" widget="many2one_tags" />

<field name="investigator" widget="many2one_tags" />

<field name="comments" widget="one2many_tags" />

<field name="witnesses" widget="many2many_tags" />

</tree>

</field>

</record>

<!-- KANBAN -->

<record id="view_kanban_sighting" model="ir.ui.view">

<field name="model">ufodata.sighting</field>

<field name="arch" type="xml">

<kanban>

<field name="case" />

<field name="identifier" />

<field name="description" />

<field name="begin" />

<field name="end" />

<field name="location" />

<templates>

<t t-name="kanban-box">

<div class="sighting_kanban_card">

<a type="open">

<field name="case" />

</a>

</div>

</t>

</templates>

</kanban>

</field>

</record>

</odoo>

Zbik

Review all views assigned to this model. You can delete them all and re-update the whole system with "-u all" parameters

Avatar
Ingbert Jüdt
Autor Mejor respuesta
(Sorry, still confusing comments and answers)


1
Avatar
Descartar
Avatar
Mrunal Gavali
Mejor respuesta

Can anyone tell me

where is existing tree view id is located. i want to use to inherit new form which will locate in tree view.

0
Avatar
Descartar
Satish Prajapati

Go to Tree view you want to inherit -> Click Debug button -> Edit View : List -> External ID

¿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
How to create tree view of sibling models ? Resuelto
treeview inheritance inherit
Avatar
1
jul 15
4542
How to Align Left [float, integer] Fields in Tree View in Odoo
treeview
Avatar
Avatar
Avatar
Avatar
3
abr 25
5908
How to do Prototpye inherit in odoo
inherit
Avatar
Avatar
Avatar
Avatar
Avatar
4
mar 24
4447
How to change column width in tree view one2many,many2many Resuelto
treeview
Avatar
Avatar
Avatar
Avatar
Avatar
5
nov 23
44354
Inheritance for account.financial.report model?
inherit
Avatar
Avatar
1
oct 23
6419
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