Skip to Content
Odoo Menu
  • Log ind
  • Prøv gratis
  • apps
    Økonomi
    • Bogføring
    • Fakturering
    • Udgifter
    • Regneark (BI)
    • Dokumenter
    • e-Signatur
    Salg
    • CRM
    • Salg
    • POS Butik
    • POS Restaurant
    • Abonnementer
    • Udlejning
    Hjemmeside
    • Hjemmesidebygger
    • e-Handel
    • Blog
    • Forum
    • LiveChat
    • e-Læring
    Forsyningskæde
    • Lagerbeholdning
    • Produktion
    • PLM
    • Indkøb
    • Vedligeholdelse
    • Kvalitet
    HR
    • Medarbejdere
    • Rekruttering
    • Fravær
    • Medarbejdersamtaler
    • Anbefalinger
    • Flåde
    Marketing
    • Markedsføring på sociale medier
    • E-mailmarketing
    • SMS-marketing
    • Arrangementer
    • Automatiseret marketing
    • Spørgeundersøgelser
    Tjenester
    • Projekt
    • Timesedler
    • Udkørende Service
    • Kundeservice
    • Planlægning
    • Aftaler
    Produktivitet
    • Dialog
    • Godkendelser
    • IoT
    • VoIP
    • Vidensdeling
    • WhatsApp
    Tredjepartsapps Odoo Studio Odoo Cloud-platform
  • Brancher
    Detailhandel
    • Boghandel
    • Tøjforretning
    • Møbelforretning
    • Dagligvarebutik
    • Byggemarked
    • Legetøjsforretning
    Mad og værtsskab
    • Bar og pub
    • Restaurant
    • Fastfood
    • Gæstehus
    • Drikkevareforhandler
    • Hotel
    Ejendom
    • Ejendomsmægler
    • Arkitektfirma
    • Byggeri
    • Ejendomsadministration
    • Havearbejde
    • Boligejerforening
    Rådgivning
    • Regnskabsfirma
    • Odoo-partner
    • Marketingbureau
    • Advokatfirma
    • Rekruttering
    • Audit & certificering
    Produktion
    • Tekstil
    • Metal
    • Møbler
    • Fødevareproduktion
    • Bryggeri
    • Firmagave
    Heldbred & Fitness
    • Sportsklub
    • Optiker
    • Fitnesscenter
    • Kosmetolog
    • Apotek
    • Frisør
    Håndværk
    • Handyman
    • IT-hardware og support
    • Solenergisystemer
    • Skomager
    • Rengøringsservicer
    • VVS- og ventilationsservice
    Andet
    • Nonprofitorganisation
    • Miljøagentur
    • Udlejning af billboards
    • Fotografi
    • Cykeludlejning
    • Softwareforhandler
    Gennemse alle brancher
  • Community
    Få mere at vide
    • Tutorials
    • Dokumentation
    • Certificeringer
    • Oplæring
    • Blog
    • Podcast
    Bliv klogere
    • Udannelselsesprogram
    • Scale Up!-virksomhedsspillet
    • Besøg Odoo
    Få softwaren
    • Download
    • Sammenlign versioner
    • Udgaver
    Samarbejde
    • Github
    • Forum
    • Arrangementer
    • Oversættelser
    • Bliv partner
    • Tjenester til partnere
    • Registrér dit regnskabsfirma
    Modtag tjenester
    • Find en partner
    • Find en bogholder
    • Kontakt en rådgiver
    • Implementeringstjenester
    • Kundereferencer
    • Support
    • Opgraderinger
    Github Youtube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Få en demo
  • Prissætning
  • Hjælp

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

  • CRM
  • e-Commerce
  • Bogføring
  • Lager
  • PoS
  • Projekt
  • MRP
All apps
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Hjælp

Trying to Create Invoices via API

Tilmeld

Få besked, når der er aktivitet på dette indlæg

Dette spørgsmål er blevet anmeldt
accountingapiAPI
2 Besvarelser
5068 Visninger
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
Kassér
Avatar
Yvan Zaugg
Bedste svar

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
Kassér
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Bedste svar

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
Kassér
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Tilmeld dig
Related Posts Besvarelser Visninger Aktivitet
Creating multiple records in one API call.
api API
Avatar
0
okt. 24
2153
How to generate accounting report via xmlrpc call odoo 17
accounting api Odoo17
Avatar
Avatar
1
jul. 25
2502
Is there a connector available for Odoo V8 to Exact Online Accounting?
accounting api odooV8
Avatar
Avatar
1
dec. 17
4428
check_total and _default_unit_price missing link
purchase accounting api
Avatar
0
mar. 15
4361
compute_taxes with XML RPC
accounting api webservices rpc
Avatar
Avatar
2
maj 24
4706
Community
  • Tutorials
  • Dokumentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Oversættelser
Tjenester
  • Odoo.sh-hosting
  • Support
  • Opgradere
  • Individuelt tilpasset udvikling
  • Uddannelse
  • Find en bogholder
  • Find en partner
  • Bliv partner
Om os
  • Vores virksomhed
  • Brandaktiver
  • Kontakt os
  • Stillinger
  • Arrangementer
  • Podcast
  • Blog
  • Kunder
  • Juridiske dokumenter • Privatlivspolitik
  • Sikkerhedspolitik
الْعَرَبيّة 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 er en samling open source-forretningsapps, der dækker alle dine virksomhedsbehov – lige fra CRM, e-handel og bogføring til lagerstyring, POS, projektledelse og meget mere.

Det unikke ved Odoo er, at systemet både er brugervenligt og fuldt integreret.

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