Ir al contenido
Odoo Menú
  • Identificarse
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • TPV para tiendas
    • TPV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en directo
    • eLearning
    Cadena de suministro
    • Inventario
    • Fabricación
    • PLM
    • Compra
    • Mantenimiento
    • Calidad
    Recursos Humanos
    • Empleados
    • Reclutamiento
    • Ausencias
    • Evaluación
    • Referencias
    • Flota
    Marketing
    • Marketing social
    • Marketing por correo electrónico
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyecto
    • Partes de horas
    • Servicio de campo
    • Servicio de asistencia
    • Planificación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Información
    • WhatsApp
    Aplicaciones de terceros Studio de Odoo Plataforma de Odoo Cloud
  • Industrias
    Comercio al por menor
    • Librería
    • Tienda de ropa
    • Tienda de muebles
    • Tienda de ultramarinos
    • Ferretería
    • Juguetería
    Food & Hospitality
    • Bar y taberna
    • Restaurante
    • Comida rápida
    • Guest House
    • Distribuidor de bebidas
    • Hotel
    Real Estate
    • Real Estate Agency
    • Estudio de arquitectura
    • Construcción
    • Gestión inmobiliaria
    • Jardinería
    • Asociación de propietarios
    Consulting
    • Accounting Firm
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Fabricación
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Regalos de empresas
    Salud y bienestar
    • Club deportivo
    • Óptica
    • Gimnasio
    • Terapeutas
    • Farmacia
    • Peluquería
    Trades
    • Handyman
    • Hardware y asistencia informática
    • Solar Energy Systems
    • Zapatero
    • Servicios de limpieza
    • HVAC Services
    Others
    • Nonprofit Organization
    • Agencia de protección del medio ambiente
    • Alquiler de paneles publicitarios
    • Estudio fotográfico
    • Alquiler de bicicletas
    • Distribuidor de software
    Browse all Industries
  • Comunidad
    Aprender
    • Tutoriales
    • Documentación
    • Certificaciones
    • Formación
    • Blog
    • Podcast
    Potenciar la educación
    • Programa de formación
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtener el software
    • Descargar
    • Comparar ediciones
    • Versiones
    Colaborar
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Convertirse en partner
    • Services for Partners
    • Registrar tu empresa contable
    Obtener servicios
    • Encontrar un partner
    • Encontrar un asesor fiscal
    • Contacta con un experto
    • Servicios de implementación
    • Referencias de clientes
    • Ayuda
    • Actualizaciones
    GitHub YouTube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicitar 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
  • Proyecto
  • 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

I don't understand the basic concepts of related fields in Odoo/OpenERP 7.0 - can someone help with examples?

Suscribirse

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

Se marcó esta pregunta
openerp7
4 Respuestas
13533 Vistas
Avatar
Karthik Arumugam

Please help me to understand the basic concepts of releated field in openerp 7.0 with simple examples

1
Avatar
Descartar
Avatar
Axel Mendoza
Mejor respuesta

A related is simply a function field capable to retrieve by itself values from relations models, typically from many2one relation models, for this you need to specify the path to the field in the target model that you want to access using the related field. This path is in the form of a sequence of arguments for the constructor of field at the begining, the rest of the arguments that not are part of the path need to be named arguments. As every function field the related need to specify it's type and in the case when the target type is a relation one like many2one, one2many or many2many, you need to specify of the relation named value with the target model of the relation. Take this examples, we will create related fields to access fields through many2one relations of the models:

class res_example1(osv.osv):
_name = 'res.example1'
_columns = {
'name': fields.char('Name', size=64),
'code': fields.char('Code', size=64),
'value': fields.float('Value'),
}
res_example1()

class res_example2(osv.osv): 
_name = 'res.example2'
_columns = {
'name': fields.char('Name', size=64),
'example_id': fields.many2one('res.example1', string='Example 1'),
'code_example': fields.related('example_id', 'code', type='char', string='Code'),
}
res_example2()

class res_example3(osv.osv): 
_name = 'res.example3'
_columns = {
'name': fields.char('Name', size=64),
'example_id': fields.many2one('res.example2', string='Example 2'),
'value_example': fields.related('example_id', 'example_id', 'value', type='float', string='Value'),
'ref_example': fields.related('example_id', 'example_id', type='many2one', relation='res.example1', string='Example 1'),
}
res_example3()

In res.example2 model the related access to the code field of the res.example1 through it's field example_id, using this path ('example_id', 'code',...) as first parameters in the field definitions. In res.example3 model we have 2 related fields, the value_example is for access the field value in res.example1, note that res.example3 has no direct relation with res.example1, thas why the arguments for path is ('example_id', 'example_id', 'value',...). Using the relation with res.example2 and res.example2 relation with res.example3 is how res.example3 related field value_example have access to the field value of res.example1. The second related in res.example3 is for show how a related to a relation target type can be done, in this case we will map the access to the field example_id in res.example2 so we need to specify the type many2one and the target relation using the relation argument.

Hope this helps

2
Avatar
Descartar
Maurice Agée

does it the same in V8 ?

Axel Mendoza

yes, you could do it using the old api or v8 api like:

nickname = fields.Char(related='user_id.partner_id.name')
Avatar
Reinhart
Mejor respuesta

Axel Mendoza's answer says it all, as an extra a simplified description would be:
* A related field is a link to another field stored in another model, as axel said, usually in a m2o relation field

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

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

Inscribirse
Publicaciones relacionadas Respuestas Vistas Actividad
Error: NameError: name 'field' is not defined
openerp7
Avatar
Avatar
Avatar
2
may 22
35088
How to add "meta viewport" tag in OpenERP v7.0?
openerp7
Avatar
0
mar 19
4932
return eval(test_expr(expr, _SAFE_OPCODES, mode=mode), globals_dict, locals_dict)
openerp7
Avatar
0
ene 19
6098
How to use ternary operator in Open-ERP7 for domain filter in XML ?
openerp7
Avatar
0
ene 18
4690
How to add calculated field to order.report ?
openerp7
Avatar
0
sept 17
5320
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento Odoo.sh
  • Ayuda
  • Actualizar
  • Desarrollos personalizados
  • Educación
  • Encontrar un asesor fiscal
  • Encontrar un partner
  • Convertirse en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contacta con nosotros
  • Puestos de trabajo
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Información 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 totalmente integrado.

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