[FIX] account: fix traceback when resetting invoice to draft (#17262)
Due to a bad refactoring of this method during the remove of the 'report' module, a traceback occurs when resetting an invoice to draft. This is due to the retrieve_attachment method that is used as an api.model instead of api.multi.
This commit is contained in:
@@ -571,7 +571,7 @@ class AccountInvoice(models.Model):
|
||||
for invoice in self:
|
||||
with invoice.env.do_in_draft():
|
||||
invoice.number, invoice.state = invoice.move_name, 'open'
|
||||
attachment = self.env['ir.actions.report'].retrieve_attachment(invoice.id)
|
||||
attachment = self.env.ref('account.account_invoices').retrieve_attachment(invoice)
|
||||
if attachment:
|
||||
attachment.unlink()
|
||||
return True
|
||||
|
||||
@@ -179,7 +179,7 @@ class IrActionsReport(models.Model):
|
||||
#--------------------------------------------------------------------------
|
||||
# Main report methods
|
||||
#--------------------------------------------------------------------------
|
||||
@api.model
|
||||
@api.multi
|
||||
def retrieve_attachment(self, record_id, attachment_name=None):
|
||||
'''Retrieve an attachment for a specific record.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user