[account] Cancelled invoice cannot be deleted after 'Reset to Draft'
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_
should be changed to:
if t['state'] in ('draft', 'cancel'):
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})