Se rendre au contenu
Odoo Menu
  • Se connecter
  • Essai gratuit
  • Applications
    Finance
    • Comptabilité
    • Facturation
    • Notes de frais
    • Feuilles de calcul (BI)
    • Documents
    • Signature
    Ventes
    • CRM
    • Ventes
    • PdV Boutique
    • PdV Restaurant
    • Abonnements
    • Location
    Sites web
    • Site Web
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Chaîne d'approvisionnement
    • Inventaire
    • Fabrication
    • PLM
    • Achats
    • Maintenance
    • Qualité
    Ressources Humaines
    • Employés
    • Recrutement
    • Congés
    • Évaluations
    • Recommandations
    • Parc automobile
    Marketing
    • Marketing Social
    • E-mail Marketing
    • SMS Marketing
    • Événements
    • Marketing Automation
    • Sondages
    Services
    • Projet
    • Feuilles de temps
    • Services sur Site
    • Assistance
    • Planification
    • Rendez-vous
    Productivité
    • Discussion
    • Validations
    • Internet des Objets
    • VoIP
    • Connaissances
    • WhatsApp
    Applications tierces Odoo Studio Plateforme Cloud d'Odoo
  • Industries
    Commerce de détail
    • Librairie
    • Magasin de vêtements
    • Magasin de meubles
    • Épicerie
    • Quincaillerie
    • Magasin de jouets
    Food & Hospitality
    • Bar et Pub
    • Restaurant
    • Fast-food
    • Maison d’hôtes
    • Distributeur de boissons
    • Hôtel
    Immobilier
    • Agence immobilière
    • Cabinet d'architecture
    • Construction
    • Gestion immobilière
    • Jardinage
    • Association de copropriétaires
    Consultance
    • Cabinet d'expertise comptable
    • Partenaire Odoo
    • Agence Marketing
    • Cabinet d'avocats
    • Aquisition de talents
    • Audit & Certification
    Fabrication
    • Textile
    • Métal
    • Meubles
    • Alimentation
    • Brewery
    • Cadeaux d'entreprise
    Santé & Fitness
    • Club de sports
    • Opticien
    • Salle de fitness
    • Praticiens bien-être
    • Pharmacie
    • Salon de coiffure
    Trades
    • Bricoleur
    • Matériel informatique et support
    • Systèmes photovoltaïques
    • Cordonnier
    • Services de nettoyage
    • Services CVC
    Autres
    • Organisation à but non lucratif
    • Agence environnementale
    • Location de panneaux d'affichage
    • Photographie
    • Leasing de vélos
    • Revendeur de logiciel
    Browse all Industries
  • Communauté
    Apprenez
    • Tutoriels
    • Documentation
    • Certifications
    • Formation
    • Blog
    • Podcast
    Renforcer l'éducation
    • Programme éducatif
    • Business Game Scale-Up!
    • Rendez-nous visite
    Obtenir le logiciel
    • Téléchargement
    • Comparez les éditions
    • Versions
    Collaborer
    • Github
    • Forum
    • Événements
    • Traductions
    • Devenez partenaire
    • Services for Partners
    • Enregistrer votre cabinet comptable
    Nos Services
    • Trouver un partenaire
    • Trouver un comptable
    • Rencontrer un conseiller
    • Services de mise en œuvre
    • Références clients
    • Assistance
    • Mises à niveau
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obtenir une démonstration
  • Tarification
  • Aide

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

  • CRM
  • e-Commerce
  • Comptabilité
  • Inventaire
  • PoS
  • Projet
  • MRP
All apps
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Aide

Create Draft Invoice via Python from a Sales Order

S'inscrire

Recevez une notification lorsqu'il y a de l'activité sur ce poste

Cette question a été signalée
pythoninvoicesalesorderautomation
3548 Vues
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
Ignorer
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.
Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !

Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !

S'inscrire
Publications associées Réponses Vues Activité
Python code in Auto action not running V16 Résolu
salesorder automation
Avatar
Avatar
Avatar
Avatar
3
mai 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 Résolu
invoice timesheet salesorder
Avatar
Avatar
1
juin 25
3318
Page Break on Sales Order/Estimates/Invoices
invoice pagebreak salesorder
Avatar
Avatar
Avatar
2
mars 24
3253
Invoice after delivery is not working. Résolu
invoice salesorder odoo16features
Avatar
Avatar
1
juin 23
2579
Communauté
  • Tutoriels
  • Documentation
  • Forum
Open Source
  • Téléchargement
  • Github
  • Runbot
  • Traductions
Services
  • Hébergement Odoo.sh
  • Assistance
  • Migration
  • Développements personnalisés
  • Éducation
  • Trouver un comptable
  • Trouver un partenaire
  • Devenez partenaire
À propos
  • Notre société
  • Actifs de la marque
  • Contactez-nous
  • Emplois
  • Événements
  • Podcast
  • Blog
  • Clients
  • Informations légales • Confidentialité
  • Sécurité.
الْعَرَبيّة 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 est une suite d'applications open source couvrant tous les besoins de votre entreprise : CRM, eCommerce, Comptabilité, Inventaire, Point de Vente, Gestion de Projet, etc.

Le positionnement unique d'Odoo est d'être à la fois très facile à utiliser et totalement intégré.

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