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.

48 lines
1.3 KiB

4 years ago
4 years ago
4 years ago
4 years ago
  1. # Copyright 2017-2020 Onestein (<https://www.onestein.eu>)
  2. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
  3. import logging
  4. from odoo import _, api, models
  5. from odoo.exceptions import UserError
  6. _logger = logging.getLogger(__name__)
  7. @api.model
  8. def _bi_view(_name):
  9. return _name.startswith("x_bve.")
  10. _auto_init_orig = models.BaseModel._auto_init
  11. def _auto_init(self):
  12. # This monkey patch is meant to fix an error (probably
  13. # introduced by https://github.com/odoo/odoo/pull/15412), while
  14. # running an update all. The _auto_init() method invoked during
  15. # an update all is the one of BaseModel, and not the one of Base.
  16. # This monkey patch seems not working if defined inside the post_load()
  17. if _bi_view(self._name):
  18. return
  19. return _auto_init_orig(self)
  20. models.BaseModel._auto_init = _auto_init
  21. class Base(models.AbstractModel):
  22. _inherit = "base"
  23. @api.model
  24. def _read_group_process_groupby(self, gb, query):
  25. if not _bi_view(self._name):
  26. return super()._read_group_process_groupby(gb, query)
  27. split = gb.split(":")
  28. if split[0] not in self._fields:
  29. raise UserError(_("No data to be displayed."))
  30. return super()._read_group_process_groupby(gb, query)