diff --git a/account_invoice_del_attachment_cancel/account_invoice.py b/account_invoice_del_attachment_cancel/account_invoice.py index 8ff4866..3861d7c 100644 --- a/account_invoice_del_attachment_cancel/account_invoice.py +++ b/account_invoice_del_attachment_cancel/account_invoice.py @@ -48,7 +48,10 @@ class AccountInvoice(models.Model): # delete attachment attach = attachs[0] 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( _('Attachement %s has been deleted') % attach_name) return res