Ir al contenido
Odoo Menú
  • Identificarse
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • TPV para tiendas
    • TPV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en directo
    • eLearning
    Cadena de suministro
    • Inventario
    • Fabricación
    • PLM
    • Compra
    • Mantenimiento
    • Calidad
    Recursos Humanos
    • Empleados
    • Reclutamiento
    • Ausencias
    • Evaluación
    • Referencias
    • Flota
    Marketing
    • Marketing social
    • Marketing por correo electrónico
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyecto
    • Partes de horas
    • Servicio de campo
    • Servicio de asistencia
    • Planificación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Conocimientos
    • WhatsApp
    Aplicaciones de terceros Studio de Odoo Plataforma de Odoo Cloud
  • Industrias
    Comercio al por menor
    • Librería
    • Tienda de ropa
    • Tienda de muebles
    • Tienda de ultramarinos
    • Ferretería
    • Juguetería
    Alimentación y hostelería
    • Bar y taberna
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidor de bebidas
    • Hotel
    Inmueble
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión inmobiliaria
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Empresa contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Fabricación
    • Textil
    • Metal
    • Muebles
    • Alimentos
    • Brewery
    • Regalos de empresas
    Salud y bienestar
    • Club deportivo
    • Óptica
    • Gimnasio
    • Terapeutas
    • Farmacia
    • Peluquería
    Oficios
    • Handyman
    • Hardware y asistencia informática
    • Sistemas de energía solar
    • Zapatero
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin ánimo de lucro
    • Agencia de protección del medio ambiente
    • Alquiler de paneles publicitarios
    • Estudio fotográfico
    • Alquiler de bicicletas
    • Distribuidor de software
    Browse all Industries
  • Comunidad
    Aprender
    • Tutoriales
    • Documentación
    • Certificaciones
    • Formación
    • Blog
    • Podcast
    Potenciar la educación
    • Programa de formación
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtener el software
    • Descargar
    • Comparar ediciones
    • Versiones
    Colaborar
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Convertirse en partner
    • Services for Partners
    • Registrar tu empresa contable
    Obtener servicios
    • Encontrar un partner
    • Encontrar un asesor fiscal
    • Contacta con un experto
    • Servicios de implementación
    • Referencias de clientes
    • Ayuda
    • Actualizaciones
    GitHub YouTube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicitar una demostración
  • Precios
  • Ayuda

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

  • CRM
  • e-Commerce
  • Contabilidad
  • Inventario
  • PoS
  • Proyecto
  • MRP
All apps
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Ayuda

Create Draft Invoice via Python from a Sales Order

Suscribirse

Reciba una notificación cuando haya actividad en esta publicación

Se marcó esta pregunta
pythoninvoicesalesorderautomation
3537 Vistas
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
Descartar
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.
¿Le interesa esta conversación? ¡Participe en ella!

Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.

Inscribirse
Publicaciones relacionadas Respuestas Vistas Actividad
Python code in Auto action not running V16 Resuelto
salesorder automation
Avatar
Avatar
Avatar
Avatar
3
may 24
3072
How to send parent record value to child record(s) using Python code and the improved Automations?
python automation
Avatar
0
nov 23
2324
Timesheet does not match to salesorder Resuelto
invoice timesheet salesorder
Avatar
Avatar
1
jun 25
3312
Page Break on Sales Order/Estimates/Invoices
invoice pagebreak salesorder
Avatar
Avatar
Avatar
2
mar 24
3246
Invoice after delivery is not working. Resuelto
invoice salesorder odoo16features
Avatar
Avatar
1
jun 23
2574
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento Odoo.sh
  • Ayuda
  • Actualizar
  • Desarrollos personalizados
  • Educación
  • Encontrar un asesor fiscal
  • Encontrar un partner
  • Convertirse en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contacta con nosotros
  • Puestos de trabajo
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Información legal • Privacidad
  • Seguridad
الْعَرَبيّة 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 es un conjunto de aplicaciones de código abierto que cubren todas las necesidades de tu empresa: CRM, comercio electrónico, contabilidad, inventario, punto de venta, gestión de proyectos, etc.

La propuesta única de valor de Odoo es ser muy fácil de usar y totalmente integrado.

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