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

JSONRPC : search_read with partner_id.country_id=76 but can not display partner_id.country_id

Suscribirse

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

Se marcó esta pregunta
jsonrpc
3 Respuestas
14071 Vistas
Avatar
cd

I use a simple JSONRPC query, to search_read all sale orders created with partners with country = 76 (France)

{"jsonrpc":"2.0","method":"call","params":{"service":"object","method":"execute","args":["admin3",1,"admin","sale.order","search_read",[["partner_id.country_id","=",76]],["name"]]},"id":"1"}

 

It's working fine.

My question is : if it's possible to search on a joined field (partner_id.country_id in this case), why it seems impossible to display the content of this joined field, in the query result ?

 

{"jsonrpc":"2.0","method":"call","params":{"service":"object","method":"execute","args":["admin3",1,"admin","sale.order","search_read",[["partner_id.country_id","=",76]],["name","partner_id.country_id"]]},"id":"1"}

 

Gives only the "name" of sale orders. Syntax problem ? Or real technical impossibility ? And if so, what would be the reason ?

0
Avatar
Descartar
Avatar
Prakash
Mejor respuesta

https://www.odoo.com/documentation/12.0/webservices/odoo.html

"sale.order" models field name defined in fields values in dictionary. If country_id field not available in the sale.order, In that case odoo custom module inherit sale.order and add related field country_id add store= True parameter it will save country_id data in database.

Domain can check res_partner.country_id, but cannot display res_partner field with dot notation. country_id field should be available in sale.order table, then only display. In that case create related field and display.

Example,

class SalesOrdercountry(models.Model):
_inherit = 'sale.order'

country_id = fields.Many2one('res.country', related='partner_id.country_id', string='Country', store=True)
models.execute_kw(db, uid, password, 'sale.order', 'search_read', [[['partner_id.country_id.id','=',79]]], {'fields': ['name', 'country_id']})
0
Avatar
Descartar
Avatar
Hutama
Mejor respuesta

First try

{"jsonrpc":"2.0","method":"call","params":{"service":"object","method":"execute","args":["admin3",1,"admin","sale.order","search_read",[["partner_id.country_id","=",76]], {}},"id":"1

You should get all data. 


Then

{"jsonrpc":"2.0","method":"call","params":{"service":"object","method":"execute","args":["admin3",1,"admin","sale.order","search_read",[["partner_id.country_id","=",76]], { "name" : [],"partner_id.country_id":[]},"id":"1

You should get name and partners country data.

Sorry if the code wrong I edit it from my phone. It work something like that

And thank you btw , your code example make my json works 

0
Avatar
Descartar
Avatar
cd
Autor Mejor respuesta

I looked at the server with the SQL debug mode... and it's not really pretty.

I thought that the ORM was capable of doing JOIN queries...

With my example, actually, the system performs first a SELECT on res.partner to retrieve the IDs of all the partners who have country = 76... In my case : a few thousands of IDs... !

And then, another SELECT... on sale.order to find SO with... partner_id among the previous list of IDs.

No JOIN queries, brutal force instead. And therefore, no way to display columns from res.partners with a simple search_read query on sale.order.

If I understand the ORM's logic, I would need to inherit the model sale.order, add a few columns (partner.id.country, or phone, or whatever else) linked to the res.partner model, I would need to work on "on change" stuff, and fix some list views.

Lot of work, isn't it?

Or do I miss something obvious ?

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
How to Fetch Product Images via JSON-RPC in Odoo?
jsonrpc
Avatar
Avatar
1
feb 25
2371
odoo 7 & jsonrpc? is this really supported? Resuelto
jsonrpc
Avatar
Avatar
2
mar 15
6279
jsonrpc to create/update data in odoo 7?
jsonrpc
Avatar
0
mar 15
4698
Odoo JSON-RPC API
api jsonrpc
Avatar
0
feb 25
2743
Usage of authenticate in JSON-RPC external API
jsonrpc odoo17
Avatar
Avatar
Avatar
Avatar
3
sept 24
14026
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