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.

32 lines
1.1 KiB

  1. # © 2016 Therp BV <http://therp.nl>
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  3. from PIL import Image
  4. from odoo.tests.common import HttpCase
  5. class TestReportQwebPdfWatermark(HttpCase):
  6. def test_report_qweb_pdf_watermark(self):
  7. Image.init()
  8. # with our image, we have three
  9. self._test_report_images(3)
  10. self.env.ref("report_qweb_pdf_watermark.demo_report").write(
  11. {"pdf_watermark_expression": False}
  12. )
  13. # without, we have two
  14. self._test_report_images(2)
  15. self.env.ref("report_qweb_pdf_watermark.demo_report").write(
  16. {"pdf_watermark": self.env.user.company_id.logo}
  17. )
  18. # and now we should have three again
  19. self._test_report_images(3)
  20. def _test_report_images(self, number):
  21. report = self.env["ir.model.data"].xmlid_to_object(
  22. "report_qweb_pdf_watermark.demo_report"
  23. )
  24. pdf, _ = report.with_context(force_report_rendering=True).render_qweb_pdf(
  25. self.env["res.users"].search([]).ids
  26. )
  27. self.assertEqual(pdf.count(b"/Subtype /Image"), number)