Ir al contenido
Odoo Menú
  • Identificarse
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • TPV para tiendas
    • TPV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en directo
    • eLearning
    Cadena de suministro
    • Inventario
    • Fabricación
    • PLM
    • Compra
    • Mantenimiento
    • Calidad
    Recursos Humanos
    • Empleados
    • Reclutamiento
    • Ausencias
    • Evaluación
    • Referencias
    • Flota
    Marketing
    • Marketing social
    • Marketing por correo electrónico
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyecto
    • Partes de horas
    • Servicio de campo
    • Servicio de asistencia
    • Planificación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Información
    • WhatsApp
    Aplicaciones de terceros Studio de Odoo Plataforma de Odoo Cloud
  • Industrias
    Comercio al por menor
    • Librería
    • Tienda de ropa
    • Tienda de muebles
    • Tienda de ultramarinos
    • Ferretería
    • Juguetería
    Food & Hospitality
    • Bar y taberna
    • Restaurante
    • Comida rápida
    • Guest House
    • Distribuidor de bebidas
    • Hotel
    Real Estate
    • Real Estate Agency
    • Estudio de arquitectura
    • Construcción
    • Gestión inmobiliaria
    • Jardinería
    • Asociación de propietarios
    Consulting
    • Accounting Firm
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Fabricación
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Regalos de empresas
    Salud y bienestar
    • Club deportivo
    • Óptica
    • Gimnasio
    • Terapeutas
    • Farmacia
    • Peluquería
    Trades
    • Handyman
    • Hardware y asistencia informática
    • Solar Energy Systems
    • Zapatero
    • Servicios de limpieza
    • HVAC Services
    Others
    • Nonprofit Organization
    • Agencia de protección del medio ambiente
    • Alquiler de paneles publicitarios
    • Estudio fotográfico
    • Alquiler de bicicletas
    • Distribuidor de software
    Browse all Industries
  • Comunidad
    Aprender
    • Tutoriales
    • Documentación
    • Certificaciones
    • Formación
    • Blog
    • Podcast
    Potenciar la educación
    • Programa de formación
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtener el software
    • Descargar
    • Comparar ediciones
    • Versiones
    Colaborar
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Convertirse en partner
    • Services for Partners
    • Registrar tu empresa contable
    Obtener servicios
    • Encontrar un partner
    • Encontrar un asesor fiscal
    • Contacta con un experto
    • Servicios de implementación
    • Referencias de clientes
    • Ayuda
    • Actualizaciones
    GitHub YouTube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicitar 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
  • Proyecto
  • 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

What does odoo store in the one2many field ?

Suscribirse

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

Se marcó esta pregunta
storeone2manydbodoo
4 Respuestas
2321 Vistas
Avatar
yahya sbini


Hi ,please I want know what is going on here !

in the sons field which is on father model (one to many) ,on sons are listed in the father record ,what does father record actually store (Sons IDs ?) ...if yes how does it stored ,is this field actually in DB dynamic array where I can ad as much sons as I want ?





0
Avatar
Descartar
yahya sbini
Autor

Could any one help !

Avatar
D Enterprise
Mejor respuesta

Hii,

No , the Father record does not directly store Son IDs in the database.

The relationship is stored on the Son model , where each Son has a foreign key (father_id) pointing back to the Father.

So:

  • Odoo's One2many field in the Father model just reads data from the Many2one field in the Son model.
  • This is not a dynamic array or list stored inside the Father row — it's a relational link across tables.

Technical Structure Behind It:

Father Model:

class Father(models.Model):

    _name = 'your.father.model'

    name = fields.Char()

    sons_ids = fields.One2many('your.son.model', 'father_id', string="Sons")


Latest Model:

class Son(models.Model):

    _name = 'your.son.model'

    name = fields.Char()

    father_id = fields.Many2one('your.father.model', string="Father")


What It Looks Like in the Database:

Table: your_father_model

ID name
1 Muhammad Sbini

Table: your_son_model:

ID name father_id
1 John 1
2 Nour 1

As you can see:

  • The father_id is stored in each Last record.
  • Odoo uses this to dynamically build the list (sons_ids) in the UI and ORM.

Is it a dynamic array?

No , it's not a real array or list in the DB.

It behaves like a list in the UI (like what you saw in your screenshot), but technically, it's just:

  • A set of son records
  • Each with a father_id equal to the current Father record

I hope it is of full use.

0
Avatar
Descartar
Avatar
Ruchita
Mejor respuesta

In Odoo, a One2many field stores a list of related records (not just IDs). Specifically, it links records from another model that have a Many2one reference back to the current model.

Internally, Odoo doesn't store data directly in the One2many field in the database. Instead, it is computed based on the Many2one field in the related model. So technically, the One2many field is not stored in the current model's table — it just provides a reverse relation for easy access to child records.

Example:

If a Sale Order has a One2many field order_line (pointing to sale.order.line), then the actual data is stored in sale.order.line using a Many2one field like order_id that points back to the sale.order.

0
Avatar
Descartar
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Mejor respuesta

Hi,

You have a Father model with a field that lists sons, that's a One2many field in Odoo.

Example:

class Father(models.Model):
_name = 'my.father'

name = fields.Char(string='Father Name')
son_ids = fields.One2many('my.son', 'father_id', string="One of my sons")

class Son(models.Model):
_name = 'my.son'

name = fields.Char(string='Son Name')
father_id = fields.Many2one('my.father', string="Father")

The One2many field does NOT directly store data in the father model's database table. Instead, it works indirectly via the reverse Many2one field in the Son model. The father_id in the my.son table (DB) stores the link (foreign key).

One2many field (like the "sons" field on the father model) is a virtual relational field; it doesn't directly store any data in the father record's database table. Instead, the actual relationship is maintained through a Many2one field on the child model (in this case, each "son" record has a father_id field pointing to its parent "father"). So, when you see a list of sons under a father, Odoo is dynamically fetching all son records from the my.son table where father_id equals that father's ID. It’s not a stored list or array in the father's table; rather, it’s a reverse lookup based on the foreign key in the child model. This makes it scalable: you can add as many sons as you want, and Odoo will always pull them dynamically using a query, not by storing their IDs in the father record.


Hope it helps.

0
Avatar
Descartar
Avatar
Accurate | www.accurates.com.sa
Mejor respuesta

Hi,

In Odoo, a one2many field (like 'sons' in your father model) doesn't actually store any data directly in the father record or table. Instead, the relationship is managed through the corresponding many2one field in the child model.

Here's what's happening:

  1. The father model has a one2many field pointing to sons: sons = fields.One2many('son.model', 'father_id', string="Sons")
  2. The son model has a many2one field pointing back to father: father_id = fields.Many2one('father.model', string="Father")
  3. In the database:
    • The father table doesn't have a column for sons
    • Each son record in the son table has a column called father_id that stores the ID of its parent

When you view a father record and see the list of sons, Odoo dynamically fetches all son records where father_id equals the current father's ID. This is done through a database query, not by accessing a stored array.

So to answer your questions directly:

  • No, the father record doesn't store sons' IDs
  • There is no array field in the database table
  • You can add as many sons as you want because each new son simply gets a new record in the son table with the appropriate father_id value

This design is a standard relational database pattern that allows for efficient storage and querying of one-to-many relationships without size limitations.

Regards,

Jishna

Accurates



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

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

Inscribirse
Publicaciones relacionadas Respuestas Vistas Actividad
how delete a Line in one2Many field ?
one2many odoo
Avatar
Avatar
Avatar
Avatar
3
jul 25
22984
Insert values to one2many field on specific record of the partner
one2many odoo
Avatar
0
sept 23
144
Enable to select an entity on one2many list Resuelto
one2many odoo
Avatar
Avatar
Avatar
2
ene 24
17003
Domain on one2many field
one2many odoo
Avatar
Avatar
1
abr 17
6599
Get active id value of One2many record which Clicked
one2many context odoo
Avatar
Avatar
1
jul 25
2531
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento Odoo.sh
  • Ayuda
  • Actualizar
  • Desarrollos personalizados
  • Educación
  • Encontrar un asesor fiscal
  • Encontrar un partner
  • Convertirse en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contacta con nosotros
  • Puestos de trabajo
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Información 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 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