mirror of
https://github.com/OCA/knowledge.git
synced 2025-07-28 03:16:29 -06:00
[14.0][MIG] attachment_category
This commit is contained in:
parent
c9bb8b6513
commit
60c249c150
@ -5,7 +5,7 @@
|
||||
"name": "Atachment Category",
|
||||
"summary": """
|
||||
Adds a document category to help classification""",
|
||||
"version": "13.0.1.0.0",
|
||||
"version": "14.0.1.0.0",
|
||||
"license": "AGPL-3",
|
||||
"author": "ACSONE SA/NV,Odoo Community Association (OCA)",
|
||||
"depends": ["base"],
|
||||
|
@ -41,11 +41,14 @@ class IrAttachmentCategory(models.Model):
|
||||
else:
|
||||
category.display_name = category.name
|
||||
|
||||
@api.depends()
|
||||
def _compute_attachment_count(self):
|
||||
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)]
|
||||
|
Loading…
Reference in New Issue
Block a user