Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

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

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

How to delete an invoice after validation?

Subscribe

Get notified when there's activity on this post

This question has been flagged
invoice
23 Replies
73307 Views
Avatar
s.salahcharki

How to delete an invoice after validation?

1
Avatar
Discard
Odoo Mates

https://www.youtube.com/watch?v=Avo42KGbkKA

Avatar
ClueLogics Technologies Pvt. Ltd.
Best Answer

Hi After validation you can't delete any invoice , for that case you can do one thing ,just refund the invoice and then cancelit

you can consider it as deleted one as it will not be counted for invoice register

Thanks
Sandeep

4
Avatar
Discard
Avatar
ravi
Best Answer

Hi, In order to Delete an invoice(which is validated), you have to edit the unlink method of account_invoice.

1) At first you have to install a account_cancel module.

2) Allow Cancelling Entries of corresponding journals.

3) After that you will have to cancel posted journal entries of that invoice.

4) then you are able to cancel the invoice. now you are ready to delete this invoice.

Go to Addons>>account module, open account_invoice.py file. find the unlink method which is same as:

def unlink(self, cr, uid, ids, context=None):
    if context is None:
        context = {}
    invoices = self.read(cr, uid, ids, ['state','internal_number'], context=context)
    unlink_ids = []
    for t in invoices:
        if t['state'] in ('draft', 'cancel') and t['internal_number']== False:
            unlink_ids.append(t['id'])
        else:
            raise osv.except_osv(_('Invalid Action!'), _('You can not delete an invoice which is not cancelled. You should refund it instead.'))
    osv.osv.unlink(self, cr, uid, unlink_ids, context=context)
    return True

Just remove "and t['internal_number']== False" from if statement or change it to "and t['internal_number']== True", and save it. after doing it you have to restart the openerp server. Now go to admin and delete the canceled invoice, it will work perfectly.

There is also an another trick, which will work every time.

In account_invoice.py in the 'action_cancel' method

self.write(cr, uid, ids, {'state':'cancel', 'move_id':False})

just replace this code with below one:

self.write(cr, uid, ids, {'state':'cancel', 'internal_number':False ,'move_id':False})

11
Avatar
Discard
Avatar
Ray Carnes
Best Answer

If the Invoice has not been paid, you can CANCEL it.

Only do this if you are sure the Invoice has not been sent to your Customer/Supplier.

6
Avatar
Discard
s.salahcharki
Author

thank you very much for your answer, but how can I remove it

Ray Carnes

Also - if you unreconcile the payments to reopen it, you can cancel an invoice previously recorded as paid.

Gopakumar N G

@Bista Solutions, I have unreconciled the payments and tried to re-open the invoice but. it's still in PAID state. This is in V7.

Agustin Ruiz Nattero

Thats right Ray, it must be very sure to do this.

Here is a few steps to make this possible.

https://www.odoo.com/forum/help-1/question/how-to-delete-a-validated-invoice-in-the-online-odoo-version-125118

Avatar
Jose Carlos Ramos Carmenates
Best Answer

How to delete an invoice after validation? On Odoo V10 (version 10)

1- To install a account_cancel module.

2- Go to file:

sudo nano /usr/lib/python2.7/dist-packages/odoo/addons/account/models/account_invoice.py

or:

addons/account/models/account_invoice.py

Note: I recommend create a save to file before.

2- Comment the function unlink like:    

    @api.multi        
def unlink(self):
        #for invoice in self:
        # #if invoice.state not in ('draft', 'cancel'):
        # # raise UserError(_('You cannot delete an invoice which is not draft or cancelled. You should refund it instead.'))
# #elif invoice.move_name:
        # # raise UserError(_('You cannot delete an invoice after it has been validated (and received a number). You can set it back to "Draft" state and modify its content, then re-confirm it.'))
return super(AccountInvoice, self).unlink()


3- Go to View and Remove the Invoce.


I hope help you!

Jose Carlos Ramos Carmenates

3
Avatar
Discard
Hamza rana

Thanks man. This was the best method. I was trying to figure this out for like 2 months.

Really appreciated.

Avatar
Cyril Gaspard (GEM)
Best Answer

Hi,

use a refund for that.

bye

1
Avatar
Discard
Avatar
Agustin Ruiz Nattero
Best Answer

 Here is my response to the same issue with a few steps to make this possible., without install any module, or addon

https://www.odoo.com/forum/help-1/question/how-to-delete-a-validated-invoice-in-the-online-odoo-version-125118

0
Avatar
Discard
Avatar
vim24
Best Answer

You can set the sales journal to allow canceling entries. by going to Configuration > Journals. Then you can cancel the invoice to remove any journal entries and the invoice will appear grayed out in your list. OR you can refund it if thats more applicable to the particular situation.

However, you shouldn't be able to delete the record completely from OpenERP, once it has been validated. Full deletion would not be fantastic accounting practice as there wouldn't be any traceability :)

Hope that helps.

0
Avatar
Discard
Claudiu Dominic Bolonyi

Hi! What if all you entries that you made until the moment you want to delete them are for test purpose only. How can you delete those entries (invoice, payments...) ?

vim24

If you are just testing, maybe its worth creating a separate database for testing purposes and keeping all your production entries in a real one. If its too late and you HAVE to remove entries you can do this manually by deleting them from postgres, but this is not advisable if there is an alternative.

Jaime

I have faced the same problem, and I have deleted all records from account_invoice* tables in openerp database. That data were not for testing, is just a bad operation For example, I have created a proforma invoice, then I needed to change the price but proforma does not allow to change it. I tried to refund, but new records were created. After some trials to cancel an invoice, I got 6 new invoices in my accounting system. So the only solution was to delete data from database.

Avatar
Piotr Kaczmarski
Best Answer

Hello,

I stuck at step 4 ... In my installation (openerp 7, python 2.6, centos) following fragment of account_invoice.py code is little different, eg:

def unlink(self, cr, uid, ids, context=None):
         if context is None:
             context = {}
         invoices = self.read(cr, uid, ids, ['state','internal_number'], context=context)
         unlink_ids = []

         for t in invoices:
             if t['state'] not in ('draft', 'cancel'):
                 raise openerp.exceptions.Warning(_('You cannot delete an invoice which is not draft or cancelled. You should refund it instead.'))
             elif t['internal_number']:
                 raise openerp.exceptions.Warning(_('You cannot delete an invoice after it has been validated (and received a number).  You can set it back to "Draft" state and modify its content, the        n re-confirm it.'))
             else:
                 unlink_ids.append(t['id'])

         osv.osv.unlink(self, cr, uid, unlink_ids, context=context)
         return True

     def onchange_partner_id(self, cr, uid, ids, type, partner_id,\
             date_invoice=False, payment_term=False, partner_bank_id=False, company_id=False):
         partner_payment_term = False
         acc_id = False
         bank_id = False
         fiscal_position = False

There is no such thing like: t['internal_number']== False. I tried delete this line, modify content sth, but installation just hangs.

Also, I can modify account_invoice.py content using second method, openerp working, but with no effect (invoice still cant be deleted). In log i have following output:

Traceback (most recent call last): File "/usr/lib/python2.6/site-packages/openerp-7.0_20130908_231053-py2.6.egg/openerp/osv/osv.py", line 131, in wrapper return f(self, dbname, args, *kwargs) File "/usr/lib/python2.6/site-packages/openerp-7.0_20130908_231053-py2.6.egg/openerp/osv/osv.py", line 197, in execute res = self.execute_cr(cr, uid, obj, method, args, *kw) File "/usr/lib/python2.6/site-packages/openerp-7.0_20130908_231053-py2.6.egg/openerp/osv/osv.py", line 185, in execute_cr return getattr(object, method)(cr, uid, args, *kw) File "/usr/lib/python2.6/site-packages/openerp-7.0_20130908_231053-py2.6.egg/openerp/addons/sale/sale.py", line 1012, in unlink return super(account_invoice, self).unlink(cr, uid, ids, context=context) File "/usr/lib/python2.6/site-packages/openerp-7.0_20130908_231053-py2.6.egg/openerp/addons/account/account_invoice.py", line 474, in unlink

Any ideas will be welcomed :)

0
Avatar
Discard
ravi

now for this situation you just comment the elif part. after that don't forget to restart the openerp server......

Avatar
Greater Global - HK
Best Answer

2) Allow Cancelling Entries of corresponding journals.

Hi, I am stuck on step 2. I have installed account_cancel module.

Yet, in settings-->>accounting-->>configuration -- I do not have any check options relating to journals. I have unistalled and re-installed account_cancel module, updated it, looked at the technical features tab etc and nothing.

It simply isn't showing up under settings. I can't select "cancel entries of corresponding journals" because I cannot find it!

any advice/ thoughts please? Very much appreciated.

0
Avatar
Discard
Ray Carnes

What you are looking for is a checkbox on the Journal form view. Accounting --> Configuration --> Journals -> Journals. Open the Journal for which you want to allow cancelling, and make sure "Allow Cancelling Entries" is checked.

Greater Global - HK

Hi Ray, thank you for taking the time to answer.

That option isn't showing. I cannot access journals under configuration. I have since discovered that the online edition doesn't allow for modules to be added / updated, thus explaining why this configuration option isn't showing up. Many thanks anyways!

Ray Carnes

The online edition allows for modules written by OpenERP to be installed. The module "Cancel Journal Entries" is one of these modules. You need to be logged in as the administrator of your database to install the module, and a member of the Technical Features group to see all of the hidden menus.

sneha antony

Is there any option same as that used to delete the invoice so that all the other documents like sales orders,delivery orders,internal moves etc can be deleted in various statuses without much difficulty?

Avatar
Peter Pisarcik
Best Answer

Hello everyone here is my fastest solution: 

  1. Install account_cancel module

  2. Cancel invoice

  3. Set invoice to draft

  4. Go to the database and find table account_invoice and set move_name = null

  5. Go back to invoices and delete an invoice

  6. Change counter in a journal back if you want

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

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

Sign up
Related Posts Replies Views Activity
change between 2 Invoice formats Solved
invoice
Avatar
Avatar
1
Jul 25
1766
Hello, how can I change the size of the logo and the invoice? Solved
invoice
Avatar
Avatar
Avatar
2
Jul 25
2142
Validation Error. You will need to clear the Journal Entry's Number to proceed
invoice
Avatar
Avatar
1
Jul 25
3082
Restricting Salesperson Access to Customer Invoice Details
invoice
Avatar
Avatar
Avatar
3
Apr 25
2946
Odoo 16 - Download invoice preview doesn't work
invoice
Avatar
Avatar
Avatar
3
Apr 25
3936
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة 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