[account] Cancelled invoice cannot be deleted after 'Reset to Draft'

Bug #978885 reported by James Jesudason
34
This bug affects 7 people
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
New
Undecided
Unassigned

Bug Description

Create an invoice and validate it, so that it generates the financial journals. Then click the 'Cancel' button on the invoice to remove the posted entries and change the state of the invoice (the module 'account_cancel' should be installed and the invoice journal should allow cancellation). Then click 'Reset to Draft' to change the invoice to the 'draft' state. Now try deleting the journal.

Expected result: the invoice should be deleted.
Actual result: error message - "You can not delete an invoice which is open or paid. We suggest you to refund it instead."

The problem is in the 'unlink' method. This checks the state of the invoice _and_ checks the 'internal_number' is False. The check on the 'internal_number' field is incorrect and should be removed.

In account_invoice.py in the 'unlink' method:

    if t['state'] in ('draft', 'cancel') and t['internal_number']== False:

should be changed to:
    if t['state'] in ('draft', 'cancel'):

Revision history for this message
Robin Bahadur (robin-bahadur) wrote :

As you said, when you validate it, internal_number field is filled by invoice number.
The proper solution is to delete internal_number when you cancel the invoice,
change in code to accomplish this.

In account_invoice.py in the 'action_cancel' method

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

should be change to:

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

Revision history for this message
Janis Elmeris (janis-elmeris) wrote :

We use this "bug" to reuse a number of a cancelled invoice, as we need all the numbers continuously.

If the cancel command removes the internal number, then, please, implement it as another command like "Cancel 2", so we can still continue using the old "Cancel" functionality!

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.