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

Create Invoice from Sales Order via xmlrpc

Subscriure's

Get notified when there's activity on this post

This question has been flagged
invoicexmlrpcsales.order
2 Respostes
6535 Vistes
Avatar
Friedrich

I created sale order in odoo 15:

 

custom_sale_order_id = models.execute_kw(db,uid, password,'sale.order', 'create',

                                    [{

                                    'company_id': int(custom_company_id),  

                                    'create_date': custom_actual_date,

                                    'create_uid': custom_create_uid,

                                    'currency_id': custom_currency_id,

                                    'date_order': custom_actual_date,

                                    'partner_id': custom_partner_id,                                      

                                    'payment_term_id': int(custom_payment_term_id), 

                                    'pricelist_id': int(custom_pricelist_id),

                                    'team_id': int(custom_crm_team),  

                                    'state': custom_sale_order_state,

                                    'invoice_status': custom_sale_order_invoice_status,

                                    'warehouse_id': custom_warehouse_id,

                                    }])

 

and 

 

custom_sale_order_line_id = models.execute_kw(db,uid, password,'sale.order.line', 'create',

                                    [{

                                    'create_date': custom_actual_date,

                                    'create_uid': custom_create_uid,

                                    'currency_id': custom_currency_id,

                                    'order_partner_id': custom_partner_id,

                                    'product_id': custom_product_id,

                                    'product_uom': int(custom_product_uom),

                                    'product_uom_qty': custom_product_qty,

                                    'qty_delivered': custom_product_qty,

                                    'order_id': custom_sale_order_id,

                                    'state': custom_sale_order_state,

                                    'invoice_status': custom_sale_order_invoice_status,

                                    }])

 

 

I’m struggling to automatically create the corresponding invoice to that sales order via xmlrpc. From sale order there is no method to create invoices.

0
Avatar
Descartar
Amr Abd-Alkrim (FireBits)

There is 2 options to do it: 

1) Call the same method that Odoo uses when you press the "Create Invoice" Button on and already created sales order. (Recommend)

2) Insert the data manually through the 'env' object in 'self' (You will have to do everything by your own throw a method in your model and call it from a button)

move_dict = {
'narration': "Name",
'ref': name,
'journal_id': journal_id.id,
'date': date,
}
line_ids = []

debit_line = {
'name': "Name",
'partner_id': partner_id.id,
'account_id': debit_account_id.id,
'journal_id': journal_id.id,
'date': date,
'debit': round(amount if amount > 0.0 else -amount),
'credit': 0.0,
'analytic_account_id': analytic_account_id,
'tax_line_id': tax_account_id,
}

credit_line = {
'name': "Name",
'partner_id': partner_id.id,
'account_id': credit_account_id.id,
'journal_id': journal_id.id,
'date': date,
'debit': 0.0,
'credit': round(amount if amount > 0.0 else -amount),
'analytic_account_id': analytic_account_id.id,
'tax_line_id': tax_account_id.id,
}

line_ids.append(debit_line)
line_ids.append(credit_line)
move_dict['line_ids'] = line_ids
move = self.env['account.move'].create(move_dict)
move.post()



Happy to help :) an upvote will be awesome

Avatar
Cédric ATANANE
Best Answer

I encountered the same issue, and here's my solution.

I understand that you want to achieve the equivalent of the following code using the XML-RPC API:

payment = self.env ["sale.advance.payment.inv"].create ({})
payment.with_context (active_ids = sale_id).create_invoices ()
1) Creating the payment:
payment = models.execute_kw(db, uid, password, 'sale.advance.payment.inv', 'create', [{
    'advance_payment_method': 'delivered',
    'create_uid': custom_create_uid,
    'currency_id': int(custom_currency_id),
    'deduct_down_payments': True,
    'deposit_account_id': False,
    'fixed_amount': 0.0,
    'has_down_payments': False,
    'write_uid': custom_create_uid,
}])

2) Creating an invoice:
payment_id = 111  # Replace with the payment ID
order_id = 222  # Replace with the sale.order ID

context = {'active_ids': [order_id]}
result = models.execute_kw(db, uid, password, 'sale.advance.payment.inv', 'create_invoices', [payment_id], {'context': context})


I hope you solved your problem beforehand or that it will help other people.

0
Avatar
Descartar
Avatar
Friedrich
Autor Best Answer

Thanks a lot for your answer. I tried option 1, also to automatically create a reference from the invoice to the underlying sales order:


First I create a “sale_advance_payment_inv” record:


        payment = models.execute_kw(db,uid, password,'sale.advance.payment.inv', 'create',

                                    [{

                                    'advance_payment_method': 'delivered',  

                                    'create_uid': custom_create_uid,

                                    'currency_id': int(custom_currency_id),

                                    'deduct_down_payments': True,

                                    'deposit_account_id': False,

                                    'fixed_amount': 0.0,

                                    'has_down_payments': False,

                                    'write_uid': custom_create_uid,

                                    }])


  

Second I wanted to create an invoice from that record but it doesn’t work:


    models.execute_kw(db, uid, password, 'sale.advance.payment.inv', 'create_invoices', [payment],{'context': action['context']})



I got the following error message and I´m not able to fix the error:


xmlrpc.client.Fault: ...

0
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
Connect sales order with already confirmed invoice Solved
invoice sales.order
Avatar
Avatar
2
de des. 22
3897
Get Orders Via XML-RPC Call Odoo 11.00
xmlrpc sales.order
Avatar
Avatar
1
de jul. 18
5927
stock.invoice.onshipping object has no attribute onchange_journal_id
invoice sales.order
Avatar
0
de juny 15
4263
merge invoice lines by product when convert from multiple sales orders
invoice invoice.line sales.order
Avatar
Avatar
Avatar
Avatar
4
de febr. 25
8076
Modify invoice content make it disconnect with its sales order
sales invoice sales.order
Avatar
Avatar
1
de gen. 25
2288
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