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
    • Información
    • 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 invoice automatically after delivery transfer is done

Suscribirse

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

Se marcó esta pregunta
triggerinvoicedeliveryorder
4 Respuestas
8710 Vistas
Avatar
Dan Witting

Hello,

i have my invoice policy set to 'delivered quantities'.

I am trying to find an automated solution to create a draft invoice after the delivery is 'done' without going manually to the sales order and click Create invoice.

I was trying to use the ODOO app Automated Actions to trigger the Invoice from the Delivery. But i did not find out how to did.

Anyone has an idea how to do it ? 

Thanks

0
Avatar
Descartar
Avatar
Dan Witting
Autor Mejor respuesta

Hello, many thanks for your solution. I have paste the Python code as you proposed. 

res = (records.origin).startswith("S0")
if res:
sale_id = env['sale.order'].search([('name','=',records.origin)])
sale_id._create_invoices()

But when i save, i receive the following Validation error message : 

IndentationError : expected an indented block at line 3 sale_id = env['sale.order'].search([('name','=',records.origin)])

Also, I am not much familar with the Python code, but i see the first line startwith("SO"). Does it mean that my Sales Order have to start with SO ? Our sales order come from different source and not all Sales Order start with 'SO". For example : Imported Sales order from an US Shopify website starts with "US", EU Shopify starts with "EU", etc. 

Many thanks

2
Avatar
Descartar
Avatar
Don Chau
Mejor respuesta

Do u solve it yet?  Trying to automated invoice for Month end too. 

1
Avatar
Descartar
Dan Witting
Autor

Yes. solved.
With Automated Actions (Technical -> Automated Actions) (with debug mode on and Automated actions module installed)

Model: Transfer
Trigger: On Update
Before Update Domain:
- Status is not 'done'
- Sales Order is Set
- Type of Operations = "outgoing"

Apply On:
- Sales Order is set
- Status = done
- Type of Operation = "outgoing"

Action to do : Execute Python code

Code used :
sale_ids = records.mapped('sale_id')
invoice_ids = []
for sale_id in sale_ids.filtered(lambda x: x.invoice_status == 'to invoice'):
invoice_ids.append(sale_id._create_invoices())
if invoice_ids:
log('Invoice created with id: %s' % ', '.join([str(i.id) for i in invoice_ids if i]), level='info')

Don Chau

Thank you, you are amazing!

Avatar
MUHAMMAD Imran
Mejor respuesta

In Odoo, you can create an invoice automatically after a delivery transfer is done by creating a new module and overriding the _action_done method of the stock.picking model.


Here is an example of how you can create an invoice automatically after a delivery transfer is done:


Create a new module, for example stock_invoice_auto.


In the models folder of your module, create a new file called stock.py and add the following code:


Copy code

from odoo import api, fields, models


class StockPicking(models.Model):

    _inherit = 'stock.picking'


    def _action_done(self):

        res = super(StockPicking, self)._action_done()

        for picking in self:

            if picking.picking_type_id.code == 'outgoing':

                invoice_id = self.env['account.move'].create({

                    'type': 'out_invoice',

                    'partner_id': picking.partner_id.id,

                    'invoice_line_ids': [

                        (0, 0, {

                            'product_id': move.product_id.id,

                            'name': move.product_id.name,

                            'quantity': move.product_uom_qty,

                            'price_unit': move.product_id.lst_price,

                            'account_id': move.product_id.categ_id.property_account_income_categ_id.id,

                        })

                        for move in picking.move_lines

                    ],

                })

                invoice_id.post()

        return res

Add the dependencies in the manifest.py file of your module

Copy code

    'depends': ['base','sale','stock'],

Update the module list and install the stock_invoice_auto module.


Once the installation is done, you can test it by creating a delivery order, and confirm it, you should see the invoice created automatically.


Please note that the above code is an example, you might need to adapt it to your specific requirements

0
Avatar
Descartar
Avatar
Jainesh Shah(Aktiv Software)
Mejor respuesta

Hello Dan Witting,

You Can Create Draft Invoice using Automated Action.


Find Example in comment.

Steps -
1) Confirm Sale Order.
2) Validate the quantity.
3) When the state changes from Ready to Done State, then your invoice will be generated.

I hope this will help you.

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari

0
Avatar
Descartar
Jainesh Shah(Aktiv Software)

For Example -

- Create an Automated action by adding name, model (Transfer as per your requirement), trigger (update as per your requirement), trigger fields(Status), Before Update domain (Status = "assigned"), filter domain (Status = "done") and Action to do ( Execute Python Code as per your requirement )

- In the Python Code Below Paste this code:-
res = (records.origin).startswith("S0")
if res:
sale_id = env['sale.order'].search([('name','=',records.origin)])
sale_id._create_invoices()

Dan Witting
Autor

Hello, many thanks for your solution. I have paste the Python code as you proposed.

res = (records.origin).startswith("S0")
if res:
sale_id = env['sale.order'].search([('name','=',records.origin)])
sale_id._create_invoices()

But when i save, i receive the following Validation error message :

IndentationError : expected an indented block at line 3 sale_id = env['sale.order'].search([('name','=',records.origin)])

Also, I am not much familar with the Python code, but i see the first line startwith("SO"). Does it mean that my Sales Order have to start with SO ? Our sales order come from different source and not all Sales Order start with 'SO". For example : Imported Sales order from an US Shopify website starts with "US", EU Shopify starts with "EU", etc.

Many thanks

¿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
A trigger that can be used to determine if an invoice has been issued Resuelto
trigger invoice
Avatar
Avatar
1
ago 24
1790
Show invoice number at delivery order page
invoice custom deliveryorder
Avatar
0
nov 17
4196
How to block deliveryorder while invoice is not paid ?
invoice v7 deliveryorder
Avatar
Avatar
3
mar 15
9498
How to view the Delivery Order associated with an Invoice
invoice v7 deliveryorder
Avatar
0
mar 15
6221
Add Invoice to Delivery Order print dialog?
invoice inventory deliveryorder odoo10
Avatar
0
jun 18
3206
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