Skip to Content
Odoo Menu
  • Prijavi
  • Try it free
  • Aplikacije
    Finance
    • Knjigovodstvo
    • Obračun
    • Stroški
    • Spreadsheet (BI)
    • Dokumenti
    • Podpisovanje
    Prodaja
    • CRM
    • Prodaja
    • POS Shop
    • POS Restaurant
    • Naročnine
    • Najem
    Spletne strani
    • Website Builder
    • Spletna trgovina
    • Blog
    • Forum
    • Pogovor v živo
    • eUčenje
    Dobavna veriga
    • Zaloga
    • Proizvodnja
    • PLM
    • Nabava
    • Vzdrževanje
    • Kakovost
    Kadri
    • Kadri
    • Kadrovanje
    • Odsotnost
    • Ocenjevanja
    • Priporočila
    • Vozni park
    Marketing
    • Družbeno Trženje
    • Email Marketing
    • SMS Marketing
    • Dogodki
    • Avtomatizacija trženja
    • Ankete
    Storitve
    • Projekt
    • Časovnice
    • Storitve na terenu
    • Služba za pomoč
    • Načrtovanje
    • Termini
    Produktivnost
    • Razprave
    • Odobritve
    • IoT
    • Voip
    • Znanje
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industrije
    Trgovina na drobno
    • Book Store
    • Trgovina z oblačili
    • Trgovina s pohištvom
    • Grocery Store
    • Trgovina s strojno opremo računalnikov
    • Trgovina z igračami
    Food & Hospitality
    • Bar and Pub
    • Restavracija
    • Hitra hrana
    • Guest House
    • Beverage Distributor
    • Hotel
    Nepremičnine
    • Real Estate Agency
    • Arhitekturno podjetje
    • Gradbeništvo
    • Estate Management
    • Vrtnarjenje
    • Združenje lastnikov nepremičnin
    Svetovanje
    • Računovodsko podjetje
    • Odoo Partner
    • Marketinška agencija
    • Law firm
    • Pridobivanje talentov
    • Audit & Certification
    Proizvodnja
    • Tekstil
    • Metal
    • Pohištvo
    • Hrana
    • Brewery
    • Poslovna darila
    Health & Fitness
    • Športni klub
    • Trgovina z očali
    • Fitnes center
    • Wellness Practitioners
    • Lekarna
    • Frizerski salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Sistemi sončne energije
    • Izdelovalec čevljev
    • Čistilne storitve
    • HVAC Services
    Ostali
    • Neprofitna organizacija
    • Agencija za okolje
    • Najem oglasnih panojev
    • Fotografija
    • Najem koles
    • Prodajalec programske opreme
    Browse all Industries
  • Skupnost
    Learn
    • Tutorials
    • Dokumentacija
    • Certifikati
    • Šolanje
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Prenesi
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Dogodki
    • Prevodi
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Sklici kupca
    • Podpora
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Določanje cen
  • Pomoč

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

  • CRM
  • e-Commerce
  • Knjigovodstvo
  • Zaloga
  • PoS
  • Projekt
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
Pomoč

Create invoice automatically after delivery transfer is done

Naroči se

Get notified when there's activity on this post

This question has been flagged
triggerinvoicedeliveryorder
4 Odgovori
8711 Prikazi
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
Opusti
Avatar
Dan Witting
Avtor Best Answer

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
Opusti
Avatar
Don Chau
Best Answer

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

1
Avatar
Opusti
Dan Witting
Avtor

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
Best Answer

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
Opusti
Avatar
Jainesh Shah(Aktiv Software)
Best Answer

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
Opusti
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
Avtor

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

Enjoying the discussion? Don't just read, join in!

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

Prijavi
Related Posts Odgovori Prikazi Aktivnost
A trigger that can be used to determine if an invoice has been issued Solved
trigger invoice
Avatar
Avatar
1
avg. 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
9499
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
Community
  • Tutorials
  • Dokumentacija
  • Forum
Open Source
  • Prenesi
  • Github
  • Runbot
  • Prevodi
Services
  • Odoo.sh Hosting
  • Podpora
  • Nadgradnja
  • Custom Developments
  • Izobraževanje
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Sredstva blagovne znamke
  • Kontakt
  • Zaposlitve
  • Dogodki
  • Podcast
  • Blog
  • Stranke
  • Pravno • Zasebnost
  • Varnost
الْعَرَبيّة 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 is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

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