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 invoice automatically after delivery transfer is done

Odoberať

Get notified when there's activity on this post

This question has been flagged
triggerinvoicedeliveryorder
4 Replies
8706 Zobrazenia
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
Zrušiť
Avatar
Dan Witting
Autor 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
Zrušiť
Avatar
Don Chau
Best Answer

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

1
Avatar
Zrušiť
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
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
Zrušiť
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
Zrušiť
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

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
A trigger that can be used to determine if an invoice has been issued Solved
trigger invoice
Avatar
Avatar
1
aug 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
6220
Add Invoice to Delivery Order print dialog?
invoice inventory deliveryorder odoo10
Avatar
0
jún 18
3205
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