Ir al contenido
Odoo Menú
  • Iniciar sesión
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • PdV para tiendas
    • PdV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en vivo
    • eLearning
    Cadena de suministro
    • Inventario
    • Manufactura
    • PLM
    • Compras
    • Mantenimiento
    • Calidad
    Recursos humanos
    • Empleados
    • Reclutamiento
    • Vacaciones
    • Evaluaciones
    • Referencias
    • Flotilla
    Marketing
    • Redes sociales
    • Marketing por correo
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyectos
    • Registro de horas
    • Servicio externo
    • Soporte al cliente
    • Planeación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Artículos
    • WhatsApp
    Aplicaciones externas Studio de Odoo Plataforma de Odoo en la nube
  • Industrias
    Venta minorista
    • Librería
    • Tienda de ropa
    • Mueblería
    • Tienda de abarrotes
    • Ferretería
    • Juguetería
    Alimentos y hospitalidad
    • Bar y pub
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidora de bebidas
    • Hotel
    Bienes inmuebles
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión de bienes inmuebles
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Firma contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Manufactura
    • Textil
    • Metal
    • Muebles
    • Comida
    • Cervecería
    • Regalos corporativos
    Salud y ejercicio
    • Club deportivo
    • Óptica
    • Gimnasio
    • Especialistas en bienestar
    • Farmacia
    • Peluquería
    Trades
    • Personal de mantenimiento
    • Hardware y soporte de TI
    • Sistemas de energía solar
    • Zapateros y fabricantes de calzado
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin fines de lucro
    • Agencia para la protección del medio ambiente
    • Alquiler de anuncios publicitarios
    • Fotografía
    • Alquiler de bicicletas
    • Distribuidor de software
    Descubre todas las industrias
  • Odoo Community
    Aprende
    • Tutoriales
    • Documentación
    • Certificaciones
    • Capacitación
    • Blog
    • Podcast
    Fortalece la educación
    • Programa educativo
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtén el software
    • Descargar
    • Compara ediciones
    • Versiones
    Colabora
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Conviértete en partner
    • Servicios para partners
    • Registra tu firma contable
    Obtén servicios
    • Encuentra un partner
    • Encuentra un contador
    • Contacta a un consultor
    • Servicios de implementación
    • Referencias de clientes
    • Soporte
    • Actualizaciones
    GitHub YouTube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicita 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
  • Proyectos
  • 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

Double Field Access? Python ORM API Odoo 11. Three dots. Confusion.

Suscribirse

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

Se marcó esta pregunta
OdooPythonORMOdoo11.0
1 Responder
3581 Vistas
Avatar
Kyle

Double Field Access??!?


I had a question about the ORM API. I am using the Python interface to Odoo. I am looking at this documentation:\https://www.odoo.com/documentation/11.0/reference/orm.html#field-access


The documentation shows how to access a field like so: table_name.column_name. However, there is another example like this: table_name.column_name.other_column_name. What does this mean? Please let me know if this does not make sense. 

Example

>>> record.name
Example Name

>>> record.company_id.name
Company Name

>>> record.name = "Bob"

>>> field = "name"

>>> record[field]
Bob
The above code shows there is a table called "record".  We do not know what columns are in this table however, which adds some confusion. We can see that we can access a column in the "record" table by doing this "record[field]" or like this "record.field".  What I am confused about is what this code is doing  -> \record.company_id.name. This seems  like  the code is referencing a column from another column. Something like if "record" is a table name. Then "company_id" is a column name. Then again "name" is also a column name. How does this make sense? What is returned? Why is the example database not shown? Is the example database shown somewhere else that I am missing? 


Thank-you for reading this!

0
Avatar
Descartar
Avatar
Ray Carnes (ray)
Mejor respuesta

This is a way of navigating relationships between tables**

Sometimes the  information  in  the field is  simple,  like  'name'.

Sometimes  the  information  in  the  field  is  relational,  like  'company_id'  and  'country_id'  in  which  case  you  can  navigate  through  the  relationship  to  the  next  table  and  get  information  from  that  one,  at any number of levels.




record.name = "Anne" for record with id =  1 when the record is a User

record.name = "ACME" for record with id = 1 when the record is a Company

record.name = "United States" for record with id = 233  when the record is a Country

record.company_id.name = "ACME" for records with id = 1, 2 and 3 when the record is a User

record.company_id.country_id.name = "United States" for records with id = 1, 2 and 3 when the record is a User

record.company_id.country_id = 233 for records with id = 1, 2 and 3 when the record is a User

record.name = "United  States" for record with id = 233 when the record is a Country


** called models in Odoo because they contain:

  •  fields of simple information stored in the PostgreSQL table
  •  fields representing relationships stored in the PostgreSQL table
  •  fields of information calculated via Python that are not stored in PostgreSQL
  •  business logic defined in Python that is not stored in PostgreSQL.


2
Avatar
Descartar
Kyle
Autor

So a triple-field is accessing multiple tables? How can I tell which tables are linked together? Or in other words, how can I tell which tables are related? Thank-you for the excellent answer. I think I understand. I at least have a much better understanding now than previously. :)

Ray Carnes (ray)

In Developer Model, use the FIELDS Menu. Filter for the model you are interested in, select just MANY2ONE fields and look at the Related Model column. If the column is blank for a given field, then that field contains simple information. If not, the model it is related to will be show in that column.

Kyle
Autor

Excellent. This is very helpful information Ray. 👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍 I appreciate you taking the time to help me understand this! 💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻

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

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

Registrarse
Publicaciones relacionadas Respuestas Vistas Actividad
Odoo python backend question
ORM
Avatar
0
ago 24
2040
When is write() triggered when updating properties of an object Resuelto
ORM
Avatar
Avatar
1
jul 24
3003
How do you add direct attributable cost to an asset...
Odoo
Avatar
0
oct 22
796
Concurrent updates of a record
ORM
Avatar
Avatar
1
mar 22
6028
how to add new magic columns?
ORM
Avatar
Avatar
1
jun 21
4035
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento en Odoo.sh
  • Soporte
  • Actualizaciones del software
  • Desarrollos personalizados
  • Educación
  • Encuentra un contador
  • Encuentra un partner
  • Conviértete en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contáctanos
  • Empleos
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • 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 estar totalmente integrado.

Sitio web hecho con

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