Se rendre au contenu
Odoo Menu
  • Se connecter
  • Essai gratuit
  • Applications
    Finance
    • Comptabilité
    • Facturation
    • Notes de frais
    • Feuilles de calcul (BI)
    • Documents
    • Signature
    Ventes
    • CRM
    • Ventes
    • PdV Boutique
    • PdV Restaurant
    • Abonnements
    • Location
    Sites web
    • Site Web
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Chaîne d'approvisionnement
    • Inventaire
    • Fabrication
    • PLM
    • Achats
    • Maintenance
    • Qualité
    Ressources Humaines
    • Employés
    • Recrutement
    • Congés
    • Évaluations
    • Recommandations
    • Parc automobile
    Marketing
    • Marketing Social
    • E-mail Marketing
    • SMS Marketing
    • Événements
    • Marketing Automation
    • Sondages
    Services
    • Projet
    • Feuilles de temps
    • Services sur Site
    • Assistance
    • Planification
    • Rendez-vous
    Productivité
    • Discussion
    • Validations
    • Internet des Objets
    • VoIP
    • Connaissances
    • WhatsApp
    Applications tierces Odoo Studio Plateforme Cloud d'Odoo
  • Industries
    Commerce de détail
    • Librairie
    • Magasin de vêtements
    • Magasin de meubles
    • Épicerie
    • Quincaillerie
    • Magasin de jouets
    Food & Hospitality
    • Bar et Pub
    • Restaurant
    • Fast-food
    • Maison d’hôtes
    • Distributeur de boissons
    • Hôtel
    Immobilier
    • Agence immobilière
    • Cabinet d'architecture
    • Construction
    • Gestion immobilière
    • Jardinage
    • Association de copropriétaires
    Consultance
    • Cabinet d'expertise comptable
    • Partenaire Odoo
    • Agence Marketing
    • Cabinet d'avocats
    • Aquisition de talents
    • Audit & Certification
    Fabrication
    • Textile
    • Métal
    • Meubles
    • Alimentation
    • Brewery
    • Cadeaux d'entreprise
    Santé & Fitness
    • Club de sports
    • Opticien
    • Salle de fitness
    • Praticiens bien-être
    • Pharmacie
    • Salon de coiffure
    Trades
    • Bricoleur
    • Matériel informatique et support
    • Systèmes photovoltaïques
    • Cordonnier
    • Services de nettoyage
    • Services CVC
    Autres
    • Organisation à but non lucratif
    • Agence environnementale
    • Location de panneaux d'affichage
    • Photographie
    • Leasing de vélos
    • Revendeur de logiciel
    Browse all Industries
  • Communauté
    Apprenez
    • Tutoriels
    • Documentation
    • Certifications
    • Formation
    • Blog
    • Podcast
    Renforcer l'éducation
    • Programme éducatif
    • Business Game Scale-Up!
    • Rendez-nous visite
    Obtenir le logiciel
    • Téléchargement
    • Comparez les éditions
    • Versions
    Collaborer
    • Github
    • Forum
    • Événements
    • Traductions
    • Devenez partenaire
    • Services for Partners
    • Enregistrer votre cabinet comptable
    Nos Services
    • Trouver un partenaire
    • Trouver un comptable
    • Rencontrer un conseiller
    • Services de mise en œuvre
    • Références clients
    • Assistance
    • Mises à niveau
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obtenir une démonstration
  • Tarification
  • Aide

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Comptabilité
  • Inventaire
  • PoS
  • Projet
  • MRP
All apps
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Aide

JSON-RPC - define request parameters like limit or fields

S'inscrire

Recevez une notification lorsqu'il y a de l'activité sur ce poste

Cette question a été signalée
jsonrpcjsonrpc
6 Réponses
13051 Vues
Avatar
AnJ

I'm trying to send JSON-RPC request using plain http POST request.
But I have trouble defining additional request option like limit or fields.

Here is my request body:
https://pastebin.com/1bkHb0Z3
​

And this is the response:

https://pastebin.com/ikV3X0Zy

When I'm sending a request without this additional contraint {"fields": ["id", "name", "email"]} I receive all the fields and I don't need them. 
Basically when I put anthing, like a limit or fields contraint, it returns only the record id and nothing else. Why? How to fix it?


2
Avatar
Ignorer
Avatar
Oscar Alca
Meilleure réponse

You need to pass the args in the same list In your request, in the pastern you are passing separately the domain and the fields, you should pass them in the same list: 


take a look at the Odoo cookbook example \https://books.google.com.mx/books?id=4NRJDwAAQBAJ&pg=PA390&lpg=PA390&dq=jsonrpc+odoo+search_read&source=bl&ots=oj5ckTbCIP&sig=ACfU3U1rTOasUKZ2wETpvaHaZ3Z8prgYhQ&hl=en&sa=X&ved=2ahUKEwiv4IWsisHnAhUXFTQIHU0NCs0Q6AEwCXoECAwQAQ#v=onepage&q=jsonrpc odoo search_read&f=false

EDIT: 

This is the right way to do what was initally asked here https://pastebin.com/MTeE4786



1
Avatar
Ignorer
AnJ
Auteur

How exactly?

I tried this:

https://pastebin.com/bS46mimc

And I'm getting an error:

"need more than 1 value to unpack"

Oscar Alca

hello, i managed to make it work like this:

https://pastebin.com/MTeE4786

If it works, do not forget to mark the answer as correct.

regards

AnJ
Auteur

Thanks, that worked. But is there any documentation about order of the parameters?

How would I know (except testing it myself) that there is method, followed by record rules, then fields, then offset, then limit? Like this:

"search_read",[["id", "=", "177"]],["id", "name", "email"],0,3

In a typical xmlrpc request parametrs like limit or fields are inside object with a assigned names, so the order does not really matters.

Oscar Alca

The only way to understand the order of the parameters is by reading the code of the api, you can reffer to Odoo's official documentation but that is not always the best way to go, for example for your request you need to find the code of the search_read method.

that can be found in odoo/odoo/api.py here is the diretct link to the method https://github.com/odoo/odoo/blob/13.0/odoo/models.py#L4799

All of Odoo's ORM core methods are in that file and they are very well documented.

additionally you can take a look at this Quora explanation about positional arguments:

https://www.quora.com/What-is-a-positional-argument-in-Python-programming

hope it helps.

Avatar
Harinath Srinivasan
Meilleure réponse

Hello Anj Just now I came across your Question I faced a Similar issue but I resolved it Here I paste my JSON request Body.

Creating Records:

{
    "jsonrpc": "2.0",
    "method": "call",
    "params": {
        "service": "object",
        "method": "execute",
        "args": [
            "<DB>",
            <UID>,
            "<password>",
            "library.book",
            "search_read",
            [["name", "ilike", "JSON"]],
            {"fields": ["name", "date_release"]}
        ]
    }
}
its Work if it useful for you kindly mark this also as an answer
1
Avatar
Ignorer
Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !

Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !

S'inscrire
Publications associées Réponses Vues Activité
Search with aggregate functions in JSON-RPC?
rpc jsonrpc
Avatar
0
juin 22
2516
How to return a simple json instead object JsonRpc? (Odoo11)
json jsonrpc odoo11
Avatar
Avatar
1
sept. 20
7235
Return reponse as standard json
json jsonrpc odoo12
Avatar
1
mars 20
4177
Odoo JSON Filter and Offset Parameter Résolu
json python3 jsonrpc
Avatar
Avatar
Avatar
5
janv. 20
11021
Selecting a specific db for a json request
json request jsonrpc
Avatar
0
mars 17
5336
Communauté
  • Tutoriels
  • Documentation
  • Forum
Open Source
  • Téléchargement
  • Github
  • Runbot
  • Traductions
Services
  • Hébergement Odoo.sh
  • Assistance
  • Migration
  • Développements personnalisés
  • Éducation
  • Trouver un comptable
  • Trouver un partenaire
  • Devenez partenaire
À propos
  • Notre société
  • Actifs de la marque
  • Contactez-nous
  • Emplois
  • Événements
  • Podcast
  • Blog
  • Clients
  • Informations légales • Confidentialité
  • Sécurité.
الْعَرَبيّة 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 est une suite d'applications open source couvrant tous les besoins de votre entreprise : CRM, eCommerce, Comptabilité, Inventaire, Point de Vente, Gestion de Projet, etc.

Le positionnement unique d'Odoo est d'être à la fois très facile à utiliser et totalement intégré.

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