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
701 B

  1. # Copyright 2020 Creu Blanca
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  3. from odoo import fields, models
  4. import logging
  5. import json
  6. logger = logging.getLogger(__name__)
  7. try:
  8. import pandas
  9. import altair
  10. except ImportError:
  11. logger.debug('Cannot import altair or pandas')
  12. class KpiKpi(models.Model):
  13. _inherit = "kpi.kpi"
  14. widget = fields.Selection(selection_add=[("altair", "Altair")])
  15. def _get_code_input_dict(self):
  16. res = super()._get_code_input_dict()
  17. if self.widget == 'altair':
  18. res.update({
  19. 'json': json,
  20. 'altair': altair,
  21. 'pandas': pandas,
  22. })
  23. return res