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
    Alimentación y hostelería
    • Bar y taberna
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidor de bebidas
    • Hotel
    Inmueble
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión inmobiliaria
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Empresa contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Fabricación
    • Textil
    • Metal
    • Muebles
    • Alimentos
    • Brewery
    • Regalos de empresas
    Salud y bienestar
    • Club deportivo
    • Óptica
    • Gimnasio
    • Terapeutas
    • Farmacia
    • Peluquería
    Oficios
    • Handyman
    • Hardware y asistencia informática
    • Sistemas de energía solar
    • Zapatero
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin ánimo de lucro
    • 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

Access an object field from another object

Suscribirse

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

Se marcó esta pregunta
newmodule
1 Responder
4462 Vistas
Avatar
Pau Ubach

I have the following situation: 

An object A has a view with a field many2one of the object B, and B has a many2one of the object C.

A also has a related field A1 which displays a field (C1) in the object C, but we can select its value directly in A view.

I can select an existing B or create a new one. The same with C.

When I select to create new B and C I get the form view for the new object C. 

 

How can I set the value in C1 to be equal to A1?

 

I'm trying with:

def default_get(self, cr, uid, fields, context=None):
            _logger.info('Inside bdd_project.default_get')
            if context is None:
                context = {}
            res = super(bdd_project, self).default_get(cr, uid, fields, context=context)
            pl_obj = self.pool.get('bdd.pricelist')
            pl = pl_obj.browse(cr, uid, context.get('cus_id'), context=context)
            if 'cus_id' in fields:
                _logger.info('Inside if cus_id: value %s', pl.cus_id)
                res.update({'cus_id': pl.cus_id})
            return res

 

where bdd_project would represent the object C and bdd_pricelist would be A.

pl.cus_id is returning None.

0
Avatar
Descartar
Avatar
Ivan
Mejor respuesta

Pau, the notion of having a related field means that you SHOULD NOT edit the value directly.  If you want to sync C1 with the value of A1 which is selected by User, then you should not define A1 as a related field, but define it as a normal field.

Then you on write (or create) of A, you can update the related C1 field value based on the value set by user.

0
Avatar
Descartar
Pau Ubach
Autor

The normal flow should be from C to A, I mean that C1 should be already defined when the view A is opened, and that's why it's a related field. But there's a rare scenario where an user could want start defining from A to C, and that's why I need to implement it this way.

Ivan

Pau, even if it is a rare chance, you still need to implement the synchronization, i.e. change A1 if C1 is updated and C1 if A1 is updated. You still can default A1 to display whatever value C1 is holding. Another approach that you may want to consider is to display B in A's form and C in B's form, hence user can change C1 from C's form instead of changing it from A's form. More longwinded for user, I understand.

Pau Ubach
Autor

John, what do you mean by implement the synchronization? Do you have a link to any document explaining how to do it? The request is to display C1 in A, and then filter B by this value.

Ivan

Pau, your first problem description is that user need to be able to change A1 and then C1 need to be change to be equal to A1. Does this still a requirement? If so, my answer stands. Synchronization is basically changing C1 when A1 is changed by user and A1 if C1 is selected by user. You need to inherit method write of both class A and C. For, say class A, you need to detect if there is any change in A1, and then change the related C1 value to be the same as A1, vv. If your first problem description is not correct, then I would suggest that you restate what you really need so the answer can be crafted more accurately.

¿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
How to debug view XML when openerp doesn't say anything about it? Resuelto
newmodule
Avatar
Avatar
Avatar
2
mar 15
8679
Adding new modules in OpenERP
newmodule
Avatar
Avatar
2
mar 15
4390
Integrity Error with calendar.event module
newmodule
Avatar
0
mar 15
4297
Display a day in a schedule for a period
newmodule
Avatar
0
mar 15
4697
MRP module installed, but not available in the home screen Resuelto
mrp newmodule
Avatar
Avatar
1
jun 16
4623
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