Skip to Content
Odoo Menú
  • Registra entrada
  • Prova-ho gratis
  • Aplicacions
    Finances
    • Comptabilitat
    • Facturació
    • Despeses
    • Full de càlcul (IA)
    • Documents
    • Signatura
    Vendes
    • CRM
    • Vendes
    • Punt de venda per a botigues
    • Punt de venda per a restaurants
    • Subscripcions
    • Lloguer
    Imatges de llocs web
    • Creació de llocs web
    • Comerç electrònic
    • Blog
    • Fòrum
    • Xat en directe
    • Aprenentatge en línia
    Cadena de subministrament
    • Inventari
    • Fabricació
    • PLM
    • Compres
    • Manteniment
    • Qualitat
    Recursos humans
    • Empleats
    • Reclutament
    • Absències
    • Avaluacions
    • Recomanacions
    • Flota
    Màrqueting
    • Màrqueting Social
    • Màrqueting per correu electrònic
    • Màrqueting per SMS
    • Esdeveniments
    • Automatització del màrqueting
    • Enquestes
    Serveis
    • Projectes
    • Fulls d'hores
    • Servei de camp
    • Suport
    • Planificació
    • Cites
    Productivitat
    • Converses
    • Validacions
    • IoT
    • VoIP
    • Coneixements
    • WhatsApp
    Aplicacions de tercers Odoo Studio Plataforma d'Odoo al núvol
  • Sectors
    Comerç al detall
    • Llibreria
    • Botiga de roba
    • Botiga de mobles
    • Botiga d'ultramarins
    • Ferreteria
    • Botiga de joguines
    Food & Hospitality
    • Bar i pub
    • Restaurant
    • Menjar ràpid
    • Guest House
    • Distribuïdor de begudes
    • Hotel
    Immobiliari
    • Agència immobiliària
    • Estudi d'arquitectura
    • Construcció
    • Gestió immobiliària
    • Jardineria
    • Associació de propietaris de béns immobles
    Consultoria
    • Empresa comptable
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Mobles
    • Menjar
    • Brewery
    • Regals corporatius
    Salut i fitness
    • Club d'esport
    • Òptica
    • Centre de fitness
    • Especialistes en benestar
    • Farmàcia
    • Perruqueria
    Trades
    • Servei de manteniment
    • Hardware i suport informàtic
    • Sistemes d'energia solar
    • Shoe Maker
    • Serveis de neteja
    • Instal·lacions HVAC
    Altres
    • Nonprofit Organization
    • Agència del medi ambient
    • Lloguer de panells publicitaris
    • Fotografia
    • Lloguer de bicicletes
    • Distribuïdors de programari
    Browse all Industries
  • Comunitat
    Aprèn
    • Tutorials
    • Documentació
    • Certificacions
    • Formació
    • Blog
    • Pòdcast
    Potenciar l'educació
    • Programa educatiu
    • Scale-Up! El joc empresarial
    • Visita Odoo
    Obtindre el programari
    • Descarregar
    • Comparar edicions
    • Novetats de les versions
    Col·laborar
    • GitHub
    • Fòrum
    • Esdeveniments
    • Traduccions
    • Converteix-te en partner
    • Services for Partners
    • Registra la teva empresa comptable
    Obtindre els serveis
    • Troba un partner
    • Troba un comptable
    • Contacta amb un expert
    • Serveis d'implementació
    • Referències del client
    • Suport
    • Actualitzacions
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Programar una demo
  • Preus
  • Ajuda

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

  • CRM
  • e-Commerce
  • Comptabilitat
  • Inventari
  • PoS
  • Projectes
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
Ajuda

Trying to Create Invoices via API

Subscriure's

Get notified when there's activity on this post

This question has been flagged
accountingapiAPI
2 Respostes
5144 Vistes
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
Descartar
Avatar
Yvan Zaugg
Best Answer

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
Descartar
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Best Answer

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

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

Registrar-se
Related Posts Respostes Vistes Activitat
Creating multiple records in one API call.
api API
Avatar
0
d’oct. 24
2159
How to generate accounting report via xmlrpc call odoo 17
accounting api Odoo17
Avatar
Avatar
1
de jul. 25
2513
Is there a connector available for Odoo V8 to Exact Online Accounting?
accounting api odooV8
Avatar
Avatar
1
de des. 17
4434
check_total and _default_unit_price missing link
purchase accounting api
Avatar
0
de març 15
4372
compute_taxes with XML RPC
accounting api webservices rpc
Avatar
Avatar
2
de maig 24
4735
Community
  • Tutorials
  • Documentació
  • Fòrum
Codi obert
  • Descarregar
  • GitHub
  • Runbot
  • Traduccions
Serveis
  • Allotjament a Odoo.sh
  • Suport
  • Actualització
  • Desenvolupaments personalitzats
  • Educació
  • Troba un comptable
  • Troba un partner
  • Converteix-te en partner
Sobre nosaltres
  • La nostra empresa
  • Actius de marca
  • Contacta amb nosaltres
  • Llocs de treball
  • Esdeveniments
  • Pòdcast
  • Blog
  • Clients
  • Informació legal • Privacitat
  • Seguretat
الْعَرَبيّة 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 és un conjunt d'aplicacions empresarials de codi obert que cobreix totes les necessitats de la teva empresa: CRM, comerç electrònic, comptabilitat, inventari, punt de venda, gestió de projectes, etc.

La proposta única de valor d'Odoo és ser molt fàcil d'utilitzar i estar totalment integrat, ambdues alhora.

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