[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
This commit is contained in:
Nicolas Martinelli
2016-04-18 10:01:26 +02:00
parent 9aa8a212d3
commit db0def38cc
+2
View File
@@ -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