Files
odoo_source/addons/account/models/ir_actions_report.py
T
Adrian Torres 4b38cc6590 [REM] *: calls to @api.multi
Multi is the default api for methods, it is not necessary to explicitly
decorate methods with it, adds clutter and most people use it because
they see that the rest of the code uses it.

Done with `find . -type f -name '*.py' | xargs sed -i '/@api.multi/d'`
2019-07-17 14:13:12 +02:00

31 lines
1.5 KiB
Python

# -*- coding: utf-8 -*-
from odoo import models, api, _
from odoo.exceptions import UserError
class IrActionsReport(models.Model):
_inherit = 'ir.actions.report'
def retrieve_attachment(self, record):
# get the original bills through the message_main_attachment_id field of the record
if self.report_name == 'account.report_original_vendor_bill' and record.message_main_attachment_id:
if record.message_main_attachment_id.mimetype == 'application/pdf' or \
record.message_main_attachment_id.mimetype.startswith('image'):
return record.message_main_attachment_id
return super(IrActionsReport, self).retrieve_attachment(record)
def _post_pdf(self, save_in_attachment, pdf_content=None, res_ids=None):
# don't include the generated dummy report
if self.report_name == 'account.report_original_vendor_bill':
pdf_content = None
res_ids = None
if not save_in_attachment:
raise UserError(_("No original vendor bills could be found for any of the selected vendor bills."))
return super(IrActionsReport, self)._post_pdf(save_in_attachment, pdf_content=pdf_content, res_ids=res_ids)
def postprocess_pdf_report(self, record, buffer):
# don't save the 'account.report_original_vendor_bill' report as it's just a mean to print existing attachments
if self.report_name == 'account.report_original_vendor_bill':
return None
return super(IrActionsReport, self).postprocess_pdf_report(record, buffer)