콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
23 답글
71793 화면

How to delete an invoice after validation?

아바타
취소
베스트 답변

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

아바타
취소
베스트 답변

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})

아바타
취소
베스트 답변

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.

아바타
취소
작성자

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

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

@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.

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

베스트 답변

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

아바타
취소

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

Really appreciated.

베스트 답변

Hi,

use a refund for that.

bye

아바타
취소
베스트 답변

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.

아바타
취소

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...) ?

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.

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.

베스트 답변

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 :)

아바타
취소

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

베스트 답변

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.

아바타
취소

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.

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!

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.

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?

베스트 답변

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

아바타
취소
베스트 답변

 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

아바타
취소
관련 게시물 답글 화면 활동
1
7월 25
753
2
7월 25
854
1
7월 25
1929
3
4월 25
1943
3
4월 25
2919