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 show all the fields

Subscriure's

Get notified when there's activity on this post

This question has been flagged
many2oneopenerp7
2 Respostes
9285 Vistes
Avatar
Hachem Chraiti

hi, im doing a many2one relation i can show the name of the relation field(foreign key) but i retrieve onlu its id, how can i retrieve other fields?

1
Avatar
Descartar
Sehrish

Enhance the functionality of Many2One fields in Odoo with dynamic multi-field Search and Get capabilities. This app allows users to search and get records within Many2One fields using multiple fields. With a user-friendly configuration interface, you can easily specify the fields to be included in the search criteria, making it more efficient and flexible for finding records as well as displaying the records based on multiple fields instead of only name field.
https://apps.odoo.com/apps/modules/17.0/mh_dynamic_name_get_many2one

Avatar
Dhinesh
Best Answer

You can use rec_name for retrieving a single value. But if u want to display more than one field means go for name_get method

def name_get(self, cr, uid, ids, context=None):
        res = []
        for obj in self.browse(cr, uid, ids, context=context):
                var = obj.name +"Email("+obj.email+")"              
            res.append((obj.id, var))
        return res

Use the above method in your parent class and simply call that class on your manytoone relational field.

Syntax of name_get orm method

name_get(cr, user, ids, context=None)
    Parameters: 

        cr -- database cursor

        user (integer) -- current user id

        ids -- list of ids

        context (dictionary) -- context arguments, like lang, time zone

    Returns:    

    tuples with the text representation of requested objects for to-many relationships
2
Avatar
Descartar
Hachem Chraiti
Autor

but th field i would like to retrive is not in the same class

Dhinesh

I have updated answer.. Check it...

Hachem Chraiti
Autor

please if im retrieving well the id how can access other fields?i must pass by sql queries?

Dhinesh

Use browse method. It will give you the entire fields in other object as well as same object. If u already have ids and want to access particular field means use search orm method.

Avatar
Prakash
Best Answer

Check many2one relation table "name" column is available. It shows "name" column value in many2one selection or add the below code in python file

rec_name = "fieldname"

Here after its shows rec_name field value shows in many2one selection.

using browse ORM method you can access all other fields.

Example:-

 def meth_name(self, cr, uid, ids, context=None):
      table_obj = self.pool.get('table.name')
      for val in table_obj.browse(cr, uid, ids, context=context):
             field1_value = val.column1
             field2_value = val.column2
      return field1_value
0
Avatar
Descartar
Hachem Chraiti
Autor

i doing this right and it shows me the field i need,but how to access to other fields????

Prakash

updated the sample code to access other fields.

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
How to fill a many2one field in openerp Solved
many2one openerp7
Avatar
Avatar
3
de gen. 19
7798
Filter only partner as is_company in many2one field on openerp 7 ? Solved
many2one openerp7
Avatar
Avatar
2
de juny 15
8655
Autofill many2one field with the "Owner" id
modules many2one openerp7
Avatar
0
de juny 15
4496
get field.related column from foreign key error - Field '_asdict' does not exist in object browse_record Solved
many2one openerp7 fields.related
Avatar
Avatar
1
d’abr. 15
7455
Python - Populating many2one field on loading of form OpenERP
python many2one openerp7
Avatar
Avatar
1
de març 15
5884
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