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 Draft Invoice via Python from a Sales Order

Odoberať

Get notified when there's activity on this post

This question has been flagged
pythoninvoicesalesorderautomation
3549 Zobrazenia
Avatar
Beauty Tribe

How do you create journal entries on an invoice from a sales order via Python? 

We have an eCommerce website and we're creating the Sales Order via the XML RPC API, without any issues. However, in order to create the invoice, I would like to use the following approach; 

- Create an automation in Odoo, which utilises a webhook as a trigger 
- In the webhook, we pass the order_id from the website (to a custom field in Odoo called x_ecom_order_id) 
- The webhook then executes python code, within which we find the Sales Order associated to the Order ID in the x_ecom_order_id custom field (this is already stored on the Sales Order) and then we call _create_invoices on the sale.order model 

All of the above works as expected and a draft invoice is correctly generated, with invoice details, including the product line items and a journal entry to recognise the revenue in Sales Account.

However, it does not automatically generate the VAT Output Credit and Accounts Receivable Debit, as per the behaviour if you manually create a draft invoice via the Odoo UI. 

Need some help and guidance on how we can automatically create the missing journal entires, prior to posting the invoice.

***********
For your reference, this is the pyhton that is executed, when we call the webhook;

# Retrieve the x_ecom_order_id from the payload

x_ecom_order_id = payload.get('x_ecom_order_id')


if x_ecom_order_id:

    sales_orders = env['sale.order'].search([('x_ecom_order_id', '=', x_ecom_order_id)], limit=1)


    if len(sales_orders) == 1:

        sales_order = sales_orders[0]


        if sales_order.invoice_status == 'to invoice':

            try:

                # Create invoices from the Sales Order

                invoice_ids = sales_order._create_invoices()

            except Exception as e:

                # Log or handle any exception during invoice creation

                pass

        else:

            # Log or handle the case where the Sales Order is not ready for invoicing

            pass

    else:

        # Log or handle the case where the Sales Order is not found or multiple are found

        pass

else:

    # Log or handle the case where x_ecom_order_id is not provided or invalid

    pass




0
Avatar
Zrušiť
OdooBot

Hello,

Thank you for reaching out.

I'm currently on my yearly vacation, and won't be available to check or respond to emails. I'll attend to your message promptly upon my return on January 02nd, 2024.

 

Regards,

Debashish Roy

Disclaimer:Grant Thornton India is a member firm of Grant Thornton International Ltd (Grant Thornton International). References to Grant Thornton are to Grant Thornton International or its member firms. Grant Thornton International and the member firms are not a worldwide partnership. Services are delivered independently by the member firms.The information contained in this e-mail is private & confidential and may also be legally privileged. While the information contained in this document and any of its attachments is provided for the assistance of the recipient, the same should not be relied upon as a substitute for professional, technical or legal advice; unless it is sent after being duly signed by a partner of our firm in hardcopy. The contents of this mail and any of its attachments are subject to change without notice. If you are not the intended recipient of this mail, please notify us, preferably by e-mail; and do not read, copy or disclose the contents of this message to anyone. Whilst we have taken reasonable precautions to ensure that any attachment to this e-mail has been swept for viruses, e-mail communications cannot be guaranteed to be secure or error free, as information can be corrupted, intercepted, lost or contain viruses. We do not accept liability for such matter or their consequences.
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
Python code in Auto action not running V16 Solved
salesorder automation
Avatar
Avatar
Avatar
Avatar
3
máj 24
3079
How to send parent record value to child record(s) using Python code and the improved Automations?
python automation
Avatar
0
nov 23
2336
Timesheet does not match to salesorder Solved
invoice timesheet salesorder
Avatar
Avatar
1
jún 25
3318
Page Break on Sales Order/Estimates/Invoices
invoice pagebreak salesorder
Avatar
Avatar
Avatar
2
mar 24
3253
Invoice after delivery is not working. Solved
invoice salesorder odoo16features
Avatar
Avatar
1
jún 23
2579
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