Skip to content
Snippets Groups Projects
Commit db0def38 authored by Nicolas Martinelli's avatar Nicolas Martinelli
Browse files

[FIX] account: delete attachment

When an invoice is cancelled, the attachments (including the printed
invoice) are not deleted. If the users resets the invoice to draft,
modify it, then print it again, the previously generated document will
be used instead.

opw-674678
parent 9aa8a212
No related branches found
No related tags found
No related merge requests found
......@@ -495,6 +495,8 @@ class AccountInvoice(models.Model):
self.write({'state': 'draft', 'date': False})
self.delete_workflow()
self.create_workflow()
# Delete attachments now since an invoice can also be generated when the invoice is cancelled
self.env['ir.attachment'].search([('res_model', '=', self._name), ('res_id', 'in', self.ids)]).unlink()
return True
@api.multi
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment