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.

33 lines
1.1 KiB

  1. # Copyright 2020 NextERP Romania SRL
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  3. from odoo import api, fields, models
  4. class IrModel(models.Model):
  5. _inherit = "ir.model"
  6. is_comment_template = fields.Boolean(
  7. string="Comment Template",
  8. default=False,
  9. help="Whether this model supports in reports to add comment templates.",
  10. )
  11. def _reflect_model_params(self, model):
  12. vals = super(IrModel, self)._reflect_model_params(model)
  13. vals["is_comment_template"] = issubclass(
  14. type(model), self.pool["comment.template"]
  15. )
  16. return vals
  17. @api.model
  18. def _instanciate(self, model_data):
  19. model_class = super(IrModel, self)._instanciate(model_data)
  20. if (
  21. model_data.get("is_comment_template")
  22. and model_class._name != "comment.template"
  23. ):
  24. parents = model_class._inherit or []
  25. parents = [parents] if isinstance(parents, str) else parents
  26. model_class._inherit = parents + ["comment.template"]
  27. return model_class