ir_actions_report.py 652 B

12345678910111213141516
  1. from odoo import _, models
  2. from odoo.exceptions import UserError
  3. class IrActionsReport(models.Model):
  4. _inherit = 'ir.actions.report'
  5. def _render_qweb_pdf(self, report_ref, res_ids=None, data=None):
  6. # Check for reports only available for invoices.
  7. if self._get_report(report_ref).report_name == 'l10n_th.report_commercial_invoice':
  8. invoices = self.env['account.move'].browse(res_ids)
  9. if any(not x.is_invoice(include_receipts=True) for x in invoices):
  10. raise UserError(_("Only invoices could be printed."))
  11. return super()._render_qweb_pdf(report_ref, res_ids=res_ids, data=data)