Add sudo to allow a user to do a back2draft even if he that doesn't have rights to delete an invoice

This commit is contained in:
Alexis de Lattre
2016-04-26 23:30:34 +02:00
parent 5be71f05b3
commit 9c67a6df5d

View File

@@ -48,7 +48,10 @@ class AccountInvoice(models.Model):
# delete attachment # delete attachment
attach = attachs[0] attach = attachs[0]
attach_name = attach.name attach_name = attach.name
attachs.unlink() # I need sudo() because the user that has the right to
# do a "back2draft" on an invoice may not have the right
# to delete an account.invoice
attachs.sudo().unlink()
invoice.message_post( invoice.message_post(
_('Attachement %s has been deleted') % attach_name) _('Attachement %s has been deleted') % attach_name)
return res return res