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.

67 lines
2.5 KiB

  1. # -*- encoding: utf-8 -*-
  2. ##############################################################################
  3. #
  4. # mis_builder module for Odoo, Management Information System Builder
  5. # Copyright (C) 2014-2015 ACSONE SA/NV (<http://acsone.eu>)
  6. #
  7. # This file is a part of mis_builder
  8. #
  9. # mis_builder is free software: you can redistribute it and/or modify
  10. # it under the terms of the GNU Affero General Public License v3 or later
  11. # as published by the Free Software Foundation, either version 3 of the
  12. # License, or (at your option) any later version.
  13. #
  14. # mis_builder is distributed in the hope that it will be useful,
  15. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. # GNU Affero General Public License v3 or later for more details.
  18. #
  19. # You should have received a copy of the GNU Affero General Public License
  20. # v3 or later along with this program.
  21. # If not, see <http://www.gnu.org/licenses/>.
  22. #
  23. ##############################################################################
  24. import logging
  25. from openerp import api, models
  26. _logger = logging.getLogger(__name__)
  27. class ReportMisReportInstance(models.AbstractModel):
  28. _name = 'report.mis_builder.report_mis_report_instance'
  29. @api.multi
  30. def render_html(self, data=None):
  31. docs = self.env['mis.report.instance'].browse(self._ids)
  32. docs_computed = {}
  33. for doc in docs:
  34. docs_computed[doc.id] = doc.compute()
  35. docargs = {
  36. 'doc_ids': self._ids,
  37. 'doc_model': 'mis.report.instance',
  38. 'docs': docs,
  39. 'docs_computed': docs_computed,
  40. }
  41. return self.env['report'].\
  42. render('mis_builder.report_mis_report_instance', docargs)
  43. class Report(models.Model):
  44. _inherit = "report"
  45. @api.v7
  46. def get_pdf(self, cr, uid, ids, report_name, html=None, data=None,
  47. context=None):
  48. if ids:
  49. report = self._get_report_from_name(cr, uid, report_name)
  50. obj = self.pool[report.model].browse(cr, uid, ids,
  51. context=context)[0]
  52. context = context.copy()
  53. if hasattr(obj, 'landscape_pdf') and obj.landscape_pdf:
  54. context.update({'landscape': True})
  55. return super(Report, self).get_pdf(cr, uid, ids, report_name,
  56. html=html, data=data,
  57. context=context)