Skip to Content
Odoo Menú
  • Registra entrada
  • Prova-ho gratis
  • Aplicacions
    Finances
    • Comptabilitat
    • Facturació
    • Despeses
    • Full de càlcul (IA)
    • Documents
    • Signatura
    Vendes
    • CRM
    • Vendes
    • Punt de venda per a botigues
    • Punt de venda per a restaurants
    • Subscripcions
    • Lloguer
    Imatges de llocs web
    • Creació de llocs web
    • Comerç electrònic
    • Blog
    • Fòrum
    • Xat en directe
    • Aprenentatge en línia
    Cadena de subministrament
    • Inventari
    • Fabricació
    • PLM
    • Compres
    • Manteniment
    • Qualitat
    Recursos humans
    • Empleats
    • Reclutament
    • Absències
    • Avaluacions
    • Recomanacions
    • Flota
    Màrqueting
    • Màrqueting Social
    • Màrqueting per correu electrònic
    • Màrqueting per SMS
    • Esdeveniments
    • Automatització del màrqueting
    • Enquestes
    Serveis
    • Projectes
    • Fulls d'hores
    • Servei de camp
    • Suport
    • Planificació
    • Cites
    Productivitat
    • Converses
    • Validacions
    • IoT
    • VoIP
    • Coneixements
    • WhatsApp
    Aplicacions de tercers Odoo Studio Plataforma d'Odoo al núvol
  • Sectors
    Comerç al detall
    • Llibreria
    • Botiga de roba
    • Botiga de mobles
    • Botiga d'ultramarins
    • Ferreteria
    • Botiga de joguines
    Food & Hospitality
    • Bar i pub
    • Restaurant
    • Menjar ràpid
    • Guest House
    • Distribuïdor de begudes
    • Hotel
    Immobiliari
    • Agència immobiliària
    • Estudi d'arquitectura
    • Construcció
    • Gestió immobiliària
    • Jardineria
    • Associació de propietaris de béns immobles
    Consultoria
    • Empresa comptable
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Mobles
    • Menjar
    • Brewery
    • Regals corporatius
    Salut i fitness
    • Club d'esport
    • Òptica
    • Centre de fitness
    • Especialistes en benestar
    • Farmàcia
    • Perruqueria
    Trades
    • Servei de manteniment
    • Hardware i suport informàtic
    • Sistemes d'energia solar
    • Shoe Maker
    • Serveis de neteja
    • Instal·lacions HVAC
    Altres
    • Nonprofit Organization
    • Agència del medi ambient
    • Lloguer de panells publicitaris
    • Fotografia
    • Lloguer de bicicletes
    • Distribuïdors de programari
    Browse all Industries
  • Comunitat
    Aprèn
    • Tutorials
    • Documentació
    • Certificacions
    • Formació
    • Blog
    • Pòdcast
    Potenciar l'educació
    • Programa educatiu
    • Scale-Up! El joc empresarial
    • Visita Odoo
    Obtindre el programari
    • Descarregar
    • Comparar edicions
    • Novetats de les versions
    Col·laborar
    • GitHub
    • Fòrum
    • Esdeveniments
    • Traduccions
    • Converteix-te en partner
    • Services for Partners
    • Registra la teva empresa comptable
    Obtindre els serveis
    • Troba un partner
    • Troba un comptable
    • Contacta amb un expert
    • Serveis d'implementació
    • Referències del client
    • Suport
    • Actualitzacions
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Programar una demo
  • Preus
  • Ajuda

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

  • CRM
  • e-Commerce
  • Comptabilitat
  • Inventari
  • PoS
  • Projectes
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
Ajuda

Many2one not filled until One2many is saved Odoo 16

Subscriure's

Get notified when there's activity on this post

This question has been flagged
many2oneone2manyodoo16features
1 Respondre
3353 Vistes
Avatar
Jort ten Donkelaar

Hi,


I have a One2many in a model, and a Many2one as an inverse. I'm noticing however that the Many2one is only filled once the One2many is saved.

The reason why this is an issue is because I want to use this Many2one in another One2many inside that child model, but I dont want to create child 1 first before having to create child 2.


So summarised:

Model 1 has a One2many of Model 2

Model 2 then has a One2many of Model 3 (and Many2one of Model 1)

Model 3 has a Many2one which has a domain, that relies on a (related) value up to Model 1. So Many2one(Model 1, related='Model 2.Model 1')

Hope this makes sense.

0
Avatar
Descartar
Jort ten Donkelaar
Autor

Ok, so as an addition to this: I sort of understand why it's going wrong, but still don't know how to fix it.
I believe it's because the original record of model 1 goes into a sort of edit-state. Which means that the many2one of model 2 only knows the edit-state version of model 1 and not the origin. I can however select the original record of model 1, after which I can do the rest (i.e. the domain is filled correctly).
So question becomes: how do I make sure the original record of model 1 is filled in the many2one in model 2?

Avatar
Ashish Hirpara
Best Answer

It sounds like you want to be able to access the fields of Model 1 from Model 3 through Model 2. To do this, you can use Odoo's relational fields.

For example, if you want to access the "name" field of Model 1 from Model 3, you can add a field to Model 3 like this:

name = fields.Char(related="model_2_id.model_1_id.name")

This will allow you to access the "name" field of Model 1 from Model 3 using the "name" field of Model 3. You can use this same technique to access any fields in Model 1 from Model 3, as long as they are accessible through the relationship between Model 2 and Model 1.

If you want to use this field in a domain filter, you can use the "name" field in the domain like this:

[('name', '=', 'some value')]

This will filter the records in Model 3 based on the value of the "name" field in Model 1.

I hope this helps! Let me know if you have any other questions.

0
Avatar
Descartar
Enjoying the discussion? Don't just read, join in!

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

Registrar-se
Related Posts Respostes Vistes Activitat
one2many fields, advise/guidance needed... Solved
one2many odoo16features
Avatar
Avatar
1
de set. 23
2606
odoo 16: Many2one - how i can another field Instead Of default Solved
many2one odoo16features
Avatar
Avatar
1
de maig 23
4422
odoo 16: Many2one field - how to return value of another field Instead Of default 'id'
many2one odoo16features
Avatar
Avatar
2
de maig 23
3998
How do I put One2many after Many2one defined? - transient module states reset
many2one one2many
Avatar
1
de març 23
3237
Odoo Studio how to set a chain of multiple and related Many2one within a One2many lines
many2one one2many
Avatar
0
de des. 22
3840
Community
  • Tutorials
  • Documentació
  • Fòrum
Codi obert
  • Descarregar
  • GitHub
  • Runbot
  • Traduccions
Serveis
  • Allotjament a Odoo.sh
  • Suport
  • Actualització
  • Desenvolupaments personalitzats
  • Educació
  • Troba un comptable
  • Troba un partner
  • Converteix-te en partner
Sobre nosaltres
  • La nostra empresa
  • Actius de marca
  • Contacta amb nosaltres
  • Llocs de treball
  • Esdeveniments
  • Pòdcast
  • Blog
  • Clients
  • Informació legal • Privacitat
  • Seguretat
الْعَرَبيّة 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 és un conjunt d'aplicacions empresarials de codi obert que cobreix totes les necessitats de la teva empresa: CRM, comerç electrònic, comptabilitat, inventari, punt de venda, gestió de projectes, etc.

La proposta única de valor d'Odoo és ser molt fàcil d'utilitzar i estar totalment integrat, ambdues alhora.

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