Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Priemyselné odvetvia
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Reštaurácia
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Reality
    • Real Estate Agency
    • Architecture Firm
    • Konštrukcia
    • Estate Managament
    • Gardening
    • Property Owner Association
    Poradenstvo
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Jedlo
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Iní
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

Create Invoice from Sales Order via xmlrpc

Odoberať

Get notified when there's activity on this post

This question has been flagged
invoicexmlrpcsales.order
2 Replies
6546 Zobrazenia
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
Zrušiť
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
Zrušiť
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
Zrušiť
Enjoying the discussion? Don't just read, join in!

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

Registrácia
Related Posts Replies Zobrazenia Aktivita
Connect sales order with already confirmed invoice Solved
invoice sales.order
Avatar
Avatar
2
dec 22
3903
Get Orders Via XML-RPC Call Odoo 11.00
xmlrpc sales.order
Avatar
Avatar
1
júl 18
5935
stock.invoice.onshipping object has no attribute onchange_journal_id
invoice sales.order
Avatar
0
jún 15
4265
merge invoice lines by product when convert from multiple sales orders
invoice invoice.line sales.order
Avatar
Avatar
Avatar
Avatar
4
feb 25
8080
Modify invoice content make it disconnect with its sales order
sales invoice sales.order
Avatar
Avatar
1
jan 25
2290
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 je sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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