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

Trying to Create Invoices via API

S'inscrire

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

Cette question a été signalée
accountingapiAPI
2 Réponses
5145 Vues
Avatar
Dan Cliff

I'm writing a solution for managing my etsy store and am using Odoo online. I can successfully create an invoice via the API using my Make.com instance, however when I try to add the line items to the invoice, I get the error 1 , shown at the bottom of this post.


I'm sure it's a syntax issue, but I'm strugging to figure out what's wrong with it.

My research suggests the issue is the curly braces inside the invoice_line_ids array, however when I remove them, I end up with Error 2.


I'm using Odoo Online with Stuido, so custom code isn't possible.


Is this a language compatibility issue, because I've witten the API call in json?


Invoice Model: account.move

My code.

[
    {
        "partner_id": 14,
        "move_type": "out_invoice",
        "invoice_date": "{{now}}",
        "invoice_date_due": "{{now}}",
        "invoice_payment_term_id": 1,
        "journal_id": 8,
        "currency_id": 173,
        "invoice_line_ids": [{
                "product_id": 9056,
                "name": "Font: Julzy",
                "quantity": 1,
                "product_uom_id": 30,
                "price_unit": 10.00,
                "discount": 0,
                "account_id": 175,
                "tax_ids": [39]
        }]
    }
]


Error 1:

RuntimeError

[1] Traceback (most recent call last): File "/home/odoo/src/odoo/18.0/odoo/addons/base/controllers/rpc.py", line 165, in xmlrpc_2 response = self._xmlrpc(service) ^^^^^^^^^^^^^^^^^^^^^ File "/home/odoo/src/custom/trial/saas_trial/controllers/main.py", line 306, in _xmlrpc res = super(OdooRPC, self)._xmlrpc(service) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/odoo/src/odoo/18.0/odoo/addons/base/controllers/rpc.py", line 139, in _xmlrpc result = dispatch_rpc(service, method, params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/odoo/src/odoo/18.0/odoo/http.py", line 398, in dispatch_rpc return dispatch(method, params) ^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/odoo/src/odoo/18.0/odoo/service/model.py", line 58, in dispatch res = execute_kw(db, uid, *params[3:]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/odoo/src/odoo/18.0/odoo/service/model.py", line 81, in execute_kw return execute(db, uid, obj, method, *args, **kw or {}) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/odoo/src/odoo/18.0/odoo/service/model.py", line 87, in execute res = execute_cr(cr, uid, obj, method, *args, **kw) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/odoo/src/odoo/18.0/odoo/service/model.py", line 72, in execute_cr result = retrying(partial(odoo.api.call_kw, recs, method, args, kw), env) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/odoo/src/odoo/18.0/odoo/service/model.py", line 156, in retrying result = func() ^^^^^^ File "/home/odoo/src/odoo/18.0/odoo/api.py", line 533, in call_kw result = getattr(recs, name)(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "<decorator-gen-214>", line 2, in create File "/home/odoo/src/odoo/18.0/odoo/api.py", line 495, in _model_create_multi return create(self, [arg]) ^^^^^^^^^^^^^^^^^^^ File "/home/odoo/src/odoo/18.0/addons/purchase/models/account_invoice.py", line 167, in create moves = super(AccountMove, self).create(vals_list) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "<decorator-gen-70>", line 2, in create File "/home/odoo/src/odoo/18.0/odoo/api.py", line 496, in _model_create_multi return create(self, arg) ^^^^^^^^^^^^^^^^^ File "/home/odoo/src/odoo/18.0/addons/account/models/account_move.py", line 3189, in create moves = super().create(vals_list) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "<decorator-gen-41>", line 2, in create File "/home/odoo/src/odoo/18.0/odoo/api.py", line 496, in _model_create_multi return create(self, arg) ^^^^^^^^^^^^^^^^^ File "/home/odoo/src/odoo/18.0/addons/mail/models/mail_thread.py", line 268, in create threads = super(MailThread, self).create(vals_list) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "<decorator-gen-0>", line 2, in create File "/home/odoo/src/odoo/18.0/odoo/api.py", line 496, in _model_create_multi return create(self, arg) ^^^^^^^^^^^^^^^^^ File "/home/odoo/src/odoo/18.0/odoo/models.py", line 5020, in create records = self._create(data_list) ^^^^^^^^^^^^^^^^^^^^^^^ File "/home/odoo/src/odoo/18.0/odoo/models.py", line 5263, in _create field.create([ File "/home/odoo/src/odoo/18.0/odoo/fields.py", line 4503, in create self.write_batch(record_values, True) File "/home/odoo/src/odoo/18.0/odoo/fields.py", line 4529, in write_batch self.write_real(records_commands_list, create) File "/home/odoo/src/odoo/18.0/odoo/fields.py", line 4714, in write_real to_link[recs[-1]].update(line_ids) File "/home/odoo/src/odoo/18.0/odoo/tools/misc.py", line 1076, in update self._map.update(zip(elems, itertools.repeat(None))) TypeError: unhashable type: 'dict'


Error 2

IMLError

Function 'createRequestBody' finished with error! Expected ',' or ']' after array element in JSON at position 312


​
0
Avatar
Ignorer
Avatar
Yvan Zaugg
Meilleure réponse

Hi Dan

for One2many and Many2many fields, you need to pass a tuple with 3 elements (see https://www.odoo.com/documentation/18.0/developer/reference/backend/orm.html#odoo.fields.Command).

You must use this format for the invoice_line_ids and tax_ids attribute.
In your case, the first element will have the value 0 (create a new record), the second value 0 (no related record) and the third the dictionary you have defined.

[
    {
        "partner_id": 14,
        "move_type": "out_invoice",
        "invoice_date": "{{now}}",
        "invoice_date_due": "{{now}}",
        "invoice_payment_term_id": 1,
        "journal_id": 8,
        "currency_id": 173,
        "invoice_line_ids": [(0, 0, {
                "product_id": 9056,
                "name": "Font: Julzy",
                "quantity": 1,
                "product_uom_id": 30,
                "price_unit": 10.00,
                "discount": 0,
                "account_id": 175,
                "tax_ids": [(0, 0, 39)]
        })]
    }
]

I hope it will work. Good luck


Best regards
Yvan

1
Avatar
Ignorer
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Meilleure réponse

Hi,

Please refer to the code below:



[

    {

        "partner_id": 14,

        "move_type": "out_invoice",

        "invoice_date": "2024-02-15",

        "invoice_date_due": "2024-02-15",

        "invoice_payment_term_id": 1,

        "journal_id": 8,

        "currency_id": 173,

        "invoice_line_ids": [

            [0, 0, {

                "product_id": 9056,

                "name": "Font: Julzy",

                "quantity": 1,

                "product_uom_id": 30,

                "price_unit": 10.00,

                "discount": 0,

                "account_id": 175,

                "tax_ids": [[0, 0, 39]]

            }]

        ]

    }

]


Hope it helps.

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é
Creating multiple records in one API call.
api API
Avatar
0
oct. 24
2159
How to generate accounting report via xmlrpc call odoo 17
accounting api Odoo17
Avatar
Avatar
1
juil. 25
2513
Is there a connector available for Odoo V8 to Exact Online Accounting?
accounting api odooV8
Avatar
Avatar
1
déc. 17
4434
check_total and _default_unit_price missing link
purchase accounting api
Avatar
0
mars 15
4374
compute_taxes with XML RPC
accounting api webservices rpc
Avatar
Avatar
2
mai 24
4735
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