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

Module: Atachment Category

Entity: ir.attachment.category

Compute Method: _compute_attachment_count

Inputs Method Outputs
  • id
category_obj = self.env["ir.attachment.category"]
attachment_obj = self.env["ir.attachment"]
for category in self:
            if isinstance(category.id, models.NewId):
                category.attachment_count = 0
                category.attachment_ids = attachment_obj.browse()
                continue
            child_categories = category_obj.search([("id", "child_of", category.id)])
            attachment_ids = attachment_obj.search(
                [("category_ids", "in", child_categories.ids)]
            )
            category.attachment_ids = attachment_ids
            category.attachment_count = len(attachment_ids)

Back to entity