Skip to Content
Odoo Menu
  • Prisijungti
  • Išbandykite nemokamai
  • Programėlės
    Finansai
    • Apskaita
    • Pateikimas apmokėjimui
    • Sąnaudos
    • Skaičiuoklė (BI)
    • Dokumentai
    • Pasirašymas
    Pardavimai
    • CRM
    • Pardavimai
    • Kasų sistema - Parduotuvė
    • Kasų sistema - Restoranas
    • Prenumeratos
    • Nuoma
    Svetainės
    • Svetainių kūrėjimo įrankis
    • El. Prekyba
    • Internetinis Tinklaraštis
    • Forumas
    • Tiesioginis pokalbis
    • eMokymasis
    Tiekimo grandinė
    • Atsarga
    • Gamyba
    • PLM
    • Įsigijimai
    • Priežiūra
    • Kokybė
    Žmogaus ištekliai
    • Darbuotojai
    • Įdarbinimas
    • Atostogos
    • Įvertinimai
    • Rekomendacijos
    • Transporto priemonės
    Rinkodara
    • Socialinė rinkodara
    • Rinkodara el. paštu
    • SMS rinkodara
    • Renginiai
    • Rinkodaros automatizavimas
    • Apklausos
    Paslaugos
    • Projektas
    • Darbo laiko žiniaraščiai
    • Priežiūros tarnyba
    • Pagalbos tarnyba
    • Planavimas
    • Rezervacijos
    Produktyvumas
    • Diskucija
    • Patvirtinimai
    • IoT
    • VoIP
    • Žinių biblioteka
    • WhatsApp
    Trečiųjų šalių programos Odoo Studija Odoo debesijos platforma
  • Pramonės šakos
    Mažmeninė prekyba
    • Knygynas
    • Drabužių parduotuvė
    • Baldų parduotuvė
    • Maisto prekių parduotuvė
    • Techninės įrangos parduotuvė
    • Žaislų parduotuvė
    Food & Hospitality
    • Barai ir pub'ai
    • Restoranas
    • Greitasis maistas
    • Guest House
    • Gėrimų platintojas
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architektūros įmonė
    • Konstrukcija
    • Estate Managament
    • Sodininkauti
    • Turto savininkų asociacija
    Consulting
    • Accounting Firm
    • Odoo Partneris
    • Marketing Agency
    • Teisinė firma
    • Talentų paieška
    • Auditai & sertifikavimas
    Gamyba
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Įmonių dovanos
    Sveikata & Fitnesas
    • Sporto klubas
    • Akinių parduotuvė
    • Fitneso Centras
    • Sveikatos praktikai
    • Vaistinė
    • Kirpėjas
    Trades
    • Handyman
    • IT įranga ir palaikymas
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Aplinkos agentūra
    • Reklaminių stendų nuoma
    • Fotografavimas
    • Dviračių nuoma
    • Programinės įrangos perpardavėjas
    Browse all Industries
  • Bendrija
    Mokykitės
    • Mokomosios medžiagos
    • Dokumentacija
    • Sertifikatai
    • Mokymai
    • Internetinis Tinklaraštis
    • Tinklalaidės
    Skatinkite švietinimą
    • Švietimo programa
    • Scale Up! Verslo žaidimas
    • Aplankykite Odoo
    Gaukite programinę įrangą
    • Atsisiųsti
    • Palyginkite versijas
    • Leidimai
    Bendradarbiauti
    • Github
    • Forumas
    • Renginiai
    • Vertimai
    • Tapkite partneriu
    • Services for Partners
    • Registruokite jūsų apskaitos įmonę
    Gaukite paslaugas
    • Susiraskite partnerį
    • Susirask buhalterį
    • Susitikti su konsultantu
    • Diegimo paslaugos
    • Klientų rekomendavimas
    • Palaikymas
    • Atnaujinimai
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Gaukite demo
  • Kainodara
  • Pagalba

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

  • CRM
  • e-Commerce
  • Apskaita
  • Atsarga
  • PoS
  • Projektas
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
Pagalba

Create Invoice from Sales Order via xmlrpc

Prenumeruoti

Get notified when there's activity on this post

This question has been flagged
invoicexmlrpcsales.order
2 Replies
6525 Rodiniai
Portretas
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
Portretas
Atmesti
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

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

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

Registracija
Related Posts Replies Rodiniai Veikla
Connect sales order with already confirmed invoice Solved
invoice sales.order
Portretas
Portretas
2
gruod. 22
3895
Get Orders Via XML-RPC Call Odoo 11.00
xmlrpc sales.order
Portretas
Portretas
1
liep. 18
5924
stock.invoice.onshipping object has no attribute onchange_journal_id
invoice sales.order
Portretas
0
birž. 15
4257
merge invoice lines by product when convert from multiple sales orders
invoice invoice.line sales.order
Portretas
Portretas
Portretas
Portretas
4
vas. 25
8075
Modify invoice content make it disconnect with its sales order
sales invoice sales.order
Portretas
Portretas
1
saus. 25
2280
Bendrija
  • Mokomosios medžiagos
  • Dokumentacija
  • Forumas
Atvirasis kodas
  • Atsisiųsti
  • Github
  • Runbot
  • Vertimai
Paslaugos
  • Odoo.sh talpinimas
  • Palaikymas
  • Atnaujinti
  • Pritaikytas programavimo kūrimas
  • Švietimas
  • Susirask buhalterį
  • Susiraskite partnerį
  • Tapkite partneriu
Apie mus
  • Mūsų įmonė
  • Prekės ženklo turtas
  • Susisiekite su mumis
  • Darbo pasiūlymai
  • Renginiai
  • Tinklalaidės
  • Internetinis Tinklaraštis
  • Klientai
  • Teisinis • Privatumas
  • Saugumas
الْعَرَبيّة 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 yra atvirojo kodo verslo programų rinkinys, kuris apima visas įmonės poreikius: CRM, El. Prekybą, Apskaitą, Atsargų, Kasų sistemą, Projektų valdymą ir kt.

Unikali Odoo vertės pasiūla – būti tuo pačiu metu labai lengvai naudojama ir visiškai integruota sistema.

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