ir_actions_report.py 911 B

12345678910111213141516171819202122232425
  1. # -*- coding: utf-8 -*-
  2. from odoo import models, fields, api, _
  3. class IrActionsReport(models.Model):
  4. _inherit = 'ir.actions.report'
  5. def retrieve_attachment(self, record):
  6. # Override this method in order to force to re-render the pdf in case of
  7. # using snailmail
  8. if self.env.context.get('snailmail_layout'):
  9. return False
  10. return super(IrActionsReport, self).retrieve_attachment(record)
  11. @api.model
  12. def get_paperformat(self):
  13. # force the right format (euro/A4) when sending letters, only if we are not using the l10n_DE layout
  14. res = super(IrActionsReport, self).get_paperformat()
  15. if self.env.context.get('snailmail_layout') and res != self.env.ref('l10n_de.paperformat_euro_din', False):
  16. paperformat_id = self.env.ref('base.paperformat_euro')
  17. return paperformat_id
  18. else:
  19. return res