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.

50 lines
1.7 KiB

  1. # -*- coding: utf-8 -*-
  2. # © 2014-2015 ACSONE SA/NV (<http://acsone.eu>)
  3. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
  4. import logging
  5. from openerp import api, models
  6. _logger = logging.getLogger(__name__)
  7. class ReportMisReportInstance(models.AbstractModel):
  8. _name = 'report.mis_builder.report_mis_report_instance'
  9. @api.multi
  10. def render_html(self, data=None):
  11. docs = self.env['mis.report.instance'].browse(self._ids)
  12. docs_computed = {}
  13. for doc in docs:
  14. docs_computed[doc.id] = doc.compute()
  15. docargs = {
  16. 'doc_ids': self._ids,
  17. 'doc_model': 'mis.report.instance',
  18. 'docs': docs,
  19. 'docs_computed': docs_computed,
  20. }
  21. return self.env['report'].\
  22. render('mis_builder.report_mis_report_instance', docargs)
  23. class Report(models.Model):
  24. _inherit = "report"
  25. @api.v7
  26. def get_pdf(self, cr, uid, ids, report_name, html=None, data=None,
  27. context=None):
  28. if not ids and context.get('active_ids') and\
  29. report_name == 'mis_builder.report_mis_report_instance':
  30. ids = context.get('active_ids')
  31. if ids:
  32. report = self._get_report_from_name(cr, uid, report_name)
  33. obj = self.pool[report.model].browse(cr, uid, ids,
  34. context=context)[0]
  35. context = context.copy()
  36. if hasattr(obj, 'landscape_pdf') and obj.landscape_pdf:
  37. context.update({'landscape': True})
  38. return super(Report, self).get_pdf(cr, uid, ids, report_name,
  39. html=html, data=data,
  40. context=context)