Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.

Module: Discuss

Entity: mail.template

Compute Method: _compute_template_category

View 19.0 View 20.0
Inputs Method Outputs
  • id
  • description
""" Base templates (or master templates) are active templates having
        a description and an XML ID. User defined templates (no xml id),
        templates without description or archived templates are not
        base templates anymore. """
deactivated = self.filtered(lambda template: not template.active)
if deactivated:
            deactivated.template_category = 'hidden_template'
remaining = self - deactivated
if remaining:
-             template_external_ids = remaining.get_external_id()
+             templates_with_xmlid = {
+                 id_
+                 for id_, xids in remaining._get_external_ids().items()
+                 if any(not xid.startswith('__export__.') for xid in xids)
+             }
            for template in remaining:
-                 if bool(template_external_ids[template.id]) and template.description:
+                 if template.id in templates_with_xmlid and template.description:
                    template.template_category = 'base_template'
-                 elif bool(template_external_ids[template.id]):
+                 elif template.id in templates_with_xmlid:
                    template.template_category = 'hidden_template'
                else:
                    template.template_category = 'custom_template'
  • template_category

Back to entity