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

odoo 16: Many2one - how i can another field Instead Of default

Subscriure's

Get notified when there's activity on this post

This question has been flagged
many2oneodoo16features
1 Respondre
4383 Vistes
Avatar
SmithJohn45

is it possible? is it correct way for Man2one field? 


i have following models:

1) coa_ledgers with id, acc_name, ledger_acc etc.
2) banks with id, bank_name, ledger_acc etc.


for my banks field 'ledger_acc' is Many2one to select from coa_ledgers and it should return the value of 'ledger_acc' field instead of 'id' field means in banks Many2one field will display 'acc_name' field and should return 'ledger_acc' field value and NOT return 'id' field value )

how i can achieve this? please help.

in my Model for banks i have Many2one field as below (by default this will Return 'id' field value from coa_ledgers to Many2one field to store the value but i want it to Return 'ledger_acc' field to store the value)

ledger_acc = fields.Many2one('coa_ledgers', string='Ledger A/c')

kindly help with all possible way(s).

regards

0
Avatar
Descartar
Avatar
Niyas Raphy (Walnut Software Solutions)
Best Answer

Hi,

When you save a many2one field, it will always save the field value to the database its ID. 

In user interface if you need to change the value displayed in the selection, either you can achieve it by adding _rec_name or by defining name_get function for the model.

As it is a many2one field and if you have a recordset of the current model, you can access anyway values inside the m20 model using the . operator, eg: self.field_name.ledger_acc


* Rec name in Odoo

* Odoo Name Get Function

* Odoo ORM


Thanks

1
Avatar
Descartar
SmithJohn45
Autor

thank you @Niyas for help. the . operator method sounds great for this purpose when we have no any other way to do this as i have asked.
will check this and confirm.
please, any link of your video guides for custom app/module how to inherit and use fields from invoice, sales, purchase etc. ( because these are have transaction level data which have deep impact in odoo system ), if there is any, please give link(s) to learn for customization with proper data handling.
regards
regards

Niyas Raphy (Walnut Software Solutions)

For adding new field in existing models: https://www.youtube.com/watch?v=46yecsKX2tw

SmithJohn45
Autor

thank you @Niyas for the link to guide.

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
odoo 16: Many2one field - how to return value of another field Instead Of default 'id'
many2one odoo16features
Avatar
Avatar
2
de maig 23
3985
many2one unlink without delete (v16)
many2one odoo odoo16features
Avatar
Avatar
1
d’abr. 24
2478
What is the best way to restrict the many2one field from opening up
many2one Odoo13.0 odoo16features
Avatar
Avatar
Avatar
2
de febr. 24
3054
[SOLVED] How to make visible selected values in many2one or many2many fields on Settings page in Odoo 16 Solved
many2one many2many odoo16features
Avatar
Avatar
Avatar
3
de des. 23
7065
many2one field is not saving
fields many2one odoo16features
Avatar
Avatar
1
d’ag. 23
3635
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