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.

33 lines
1.2 KiB

  1. # Copyright 2015 ACSONE SA/NV (<http://acsone.eu>)
  2. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
  3. from odoo import api, fields, models, _
  4. from odoo.exceptions import UserError
  5. class ReportAction(models.Model):
  6. _inherit = 'ir.actions.report'
  7. report_type = fields.Selection(selection_add=[("xlsx", "xlsx")])
  8. @api.model
  9. def render_xlsx(self, docids, data):
  10. report_model_name = 'report.%s' % self.report_name
  11. report_model = self.env.get(report_model_name)
  12. if report_model is None:
  13. raise UserError(_('%s model was not found' % report_model_name))
  14. return report_model.with_context({
  15. 'active_model': self.model
  16. }).create_xlsx_report(docids, data)
  17. @api.model
  18. def _get_report_from_name(self, report_name):
  19. res = super(ReportAction, self)._get_report_from_name(report_name)
  20. if res:
  21. return res
  22. report_obj = self.env['ir.actions.report']
  23. qwebtypes = ['xlsx']
  24. conditions = [('report_type', 'in', qwebtypes),
  25. ('report_name', '=', report_name)]
  26. context = self.env['res.users'].context_get()
  27. return report_obj.with_context(context).search(conditions, limit=1)