[14.0][MIG] attachment_category

This commit is contained in:
Denis Roussel 2020-10-18 15:18:47 +02:00 committed by Pierrick Brun
parent c9bb8b6513
commit 60c249c150
2 changed files with 5 additions and 2 deletions

View File

@ -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"],

View File

@ -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)]