Přejít na obsah
Odoo Menu
  • Přihlásit se
  • Vyzkoušejte zdarma
  • Aplikace
    Finance
    • Účetnictví
    • Fakturace
    • Výdaje
    • Spreadsheet (BI)
    • Dokumenty
    • Podpisy
    Prodej
    • CRM
    • Prodej
    • POS Obchod
    • POS Restaurace
    • Předplatné
    • Pronájem
    Webové stránky
    • Webové stránky
    • E-shop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Dodavatelský řetězec
    • Sklad
    • Výroba
    • PLM
    • Nákup
    • Údržba
    • Kvalita
    Lidské zdroje
    • Zaměstnanci
    • Nábor
    • Volno
    • Hodnocení zaměstnanců
    • Doporučení
    • Vozový park
    Marketing
    • Marketing sociálních sítí
    • Emailový marketing
    • SMS Marketing
    • Události
    • Marketingová automatizace
    • Dotazníky
    Služby
    • Projekt
    • Časové výkazy
    • Práce v terénu
    • Helpdesk
    • Plánování
    • Schůzky
    Produktivita
    • Diskuze
    • Schvalování
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Aplikace třetích stran Odoo Studio Odoo cloudová platforma
  • Branže
    Maloobchod
    • Knihkupectví
    • Obchod s oblečením
    • Obchod s nábytkem
    • Potraviny
    • Obchod s hardwarem
    • Hračkářství
    Jídlo a pohostinství
    • Bar a Pub
    • Restaurace
    • Fast Food
    • Penzion
    • Distributor nápojů
    • Hotel
    Nemovitost
    • Realitní kancelář
    • Architektonická firma
    • Stavba
    • Správa nemovitostí
    • Zahradnictví
    • Asociace vlastníků nemovitosti
    Poradenství
    • Účetní firma
    • Odoo Partner
    • Marketingová agentura
    • Právník
    • Akvizice talentů
    • Audit a certifikace
    Výroba
    • Textile
    • Kov
    • Nábytek
    • Jídlo
    • Brewery
    • Korporátní dárky
    Zdraví a fitness
    • Sportovní klub
    • Prodejna brýli
    • Fitness Centrum
    • Wellness praktikové
    • Lékárna
    • Kadeřnictví
    Transakce
    • Údržbář
    • IT hardware a podpora
    • Systémy solární energie
    • Výrobce obuvi
    • Úklidové služby
    • Služby HVAC
    Ostatní
    • Nezisková organizace
    • Agentura pro životní prostředí
    • Pronájem billboardů
    • Fotografování
    • Leasing jízdních kol
    • Prodejce softwaru
    Browse all Industries
  • Komunita
    Edukační program
    • Tutoriály
    • Dokumentace
    • Certifikace
    • Vzdělávání
    • Blog
    • Podcast
    Podpora vzdělávání
    • Vzdělávací program
    • Scale Up! Hra na firmu
    • Navštivte Odoo
    Získat software
    • Stáhnout
    • Porovnejte edice
    • Verze
    Spolupráce
    • Github
    • Fórum
    • Události
    • Překlady
    • Stát se partnerem
    • Services for Partners
    • Registrujte svou účetní firmu
    Získat služby
    • Najít partnera
    • Najít účetní
    • Setkejte se s poradcem
    • Implementační služby
    • Zákaznické reference
    • Podpora
    • Upgrady
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dohodnout demo
  • Ceník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účetnictví
  • Sklad
  • PoS
  • Projekty
  • MRP
All apps
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
Pomoc

What does odoo store in the one2many field ?

Odebírat

Get notified when there's activity on this post

This question has been flagged
storeone2manydbodoo
4 Odpovědi
2373 Zobrazení
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
Zrušit
yahya sbini
Autor

Could any one help !

Avatar
D Enterprise
Nejlepší odpověď

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
Zrušit
Avatar
Ruchita
Nejlepší odpověď

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
Zrušit
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Nejlepší odpověď

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
Zrušit
Avatar
Accurate | www.accurates.com.sa
Nejlepší odpověď

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
Zrušit
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Přihlásit se
Related Posts Odpovědi Zobrazení Aktivita
how delete a Line in one2Many field ?
one2many odoo
Avatar
Avatar
Avatar
Avatar
3
čvc 25
23030
Insert values to one2many field on specific record of the partner
one2many odoo
Avatar
0
zář 23
144
Enable to select an entity on one2many list Vyřešeno
one2many odoo
Avatar
Avatar
Avatar
2
led 24
17035
Domain on one2many field
one2many odoo
Avatar
Avatar
1
dub 17
6624
Get active id value of One2many record which Clicked
one2many context odoo
Avatar
Avatar
1
čvc 25
2563
Komunita
  • Tutoriály
  • Dokumentace
  • Fórum
Open Source
  • Stáhnout
  • Github
  • Runbot
  • Překlady
Služby
  • Odoo.sh hostování
  • Podpora
  • Upgrade
  • Nestandardní vývoj
  • Edukační program
  • Najít účetní
  • Najít partnera
  • Stát se partnerem
O nás
  • Naše společnost
  • Podklady značky
  • Kontakujte nás
  • Práce
  • Události
  • Podcast
  • Blog
  • Zákazníci
  • Právní dokumenty • Soukromí
  • Zabezpečení
الْعَرَبيّة 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 je balíček open-source aplikací, které pokrývají všechny potřeby vaší společnosti: CRM, e-shop, účetnictví, sklady, kasy, projektové řízení a další.

Unikátní nabídka od Odoo poskytuje velmi jednoduché uživatelské rozhraní a vše je integrované na jednom místě.

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