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

Get a list on Customer Contact Names in sale.order form view

Suscribirse

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

Se marcó esta pregunta
domainmany2oneres.partnerchild_idsodoo11
1 Responder
8150 Vistas
Avatar
Arpit Thakar

I have created a Customer and that customers has 3 contact person names. Now while creating the Sales Order, I want to select 1 contact person name from a list. How can I get only the names of the contact person into a field?

I have created a related field in my custom module and in the form view I have displayed it :

custom.py

customer_contact = fields.Char(related="partner_id.child_ids.name", string="Contact Person", )

custom_saleorder_views.xml

<xpath expr="//field[@name='partner_shipping_id']" position="after">
<!-- Add your fields or attributes here -->
<field name="customer_contact" />
</xpath>

I have displayed the field below the Delivery address.

Now when I select the customer in Sales Order form view, it gives only the first contact person name. The rest of the contact names are not displayed.

How to get a list of contact names in the field "customer_contact". As the default field type of 'name' field is 'Char', using many2one field in our custom module gives a error.

0
Avatar
Descartar
Avatar
Dhaval Desai
Mejor respuesta

Hi,

you can not used related="partner_id.child_ids.name" because  child_ids is One2many field

One2many fields does not work in related. 

Please try below Example:

customer_contact = fields.Char(string="Contact Person" )

@api.onchange('partner_id')

def get_customer_contact_person(self):

    if self.partner_id and self.partner_id.child_ids:

        for person in self.partner_id.child_ids:

            self.customer_contact =  ' '.join(person.name)

Make sure it will helpful.

Thank You.


0
Avatar
Descartar
Arpit Thakar
Autor

Hi Dhaval,

I tried you code, but it game me the following error. Can you please help me in solving this error.

line 66, in get_customer_contact_person

self.customer_contact = ''.join(person.name)

TypeError: can only join an iterable

Dhaval Desai

Hello Arpit,

you can try below:

def get_customer_contact_person(self):

if self.partner_id and self.partner_id.child_ids:

self.customer_contact = ' '.join(str(person.name) for person in self.partner_id.child_ids)

Arpit Thakar
Autor

Hi Dhaval,

Your updated solution is working well without any problem. Thank you for your prompt answer.

With your code I am getting contact person names, but not as a drop down list. I want to select only one contact person from 3 or 4 persons.

So can you help me in getting a drop down menu for contact persons.

Thanks for your previous answers.

¿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
verify that client has at least one contact
customer res.partner child_ids odoo11
Avatar
Avatar
Avatar
3
sept 18
2341
How to only show companies in a many2one field ?
domain many2one res.partner company related
Avatar
Avatar
Avatar
2
mar 15
9772
how can use output of function in domain of field? Resuelto
domain odoo11
Avatar
Avatar
Avatar
2
jul 24
8849
Domain with inherited field Resuelto
domain many2one
Avatar
1
oct 22
4702
Why many2one field sets to null when I save record? Resuelto
many2one odoo11
Avatar
Avatar
Avatar
2
jun 20
7317
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