OCA reporting engine fork for dev and update.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
1.0 KiB

  1. # -*- coding: utf-8 -*-
  2. # © 2016-2018 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  4. from odoo import api, fields, models
  5. class IrActionsReportXml(models.Model):
  6. _inherit = 'ir.actions.report.xml'
  7. report_type = fields.Selection(selection_add=[
  8. ('qweb-txt', 'Text'),
  9. ('qweb-txt-csv', 'CSV'),
  10. ])
  11. @api.model
  12. def render_report(self, res_ids, name, data):
  13. if (
  14. data.get('report_type') and
  15. data.get('report_type').startswith('qweb-txt')):
  16. ext = data['report_type'].split('-')[-1]
  17. # That way, you can easily add qweb-txt-zpl' or others
  18. # without inheriting this method (you just need to do the
  19. # selection_add on the field 'report_type')
  20. return self.env['report'].get_html(res_ids, name, data=data), ext
  21. else:
  22. return super(IrActionsReportXml, self).render_report(
  23. res_ids, name, data)