diff --git a/attachment_category/__manifest__.py b/attachment_category/__manifest__.py index 5a09a117..30c71f89 100644 --- a/attachment_category/__manifest__.py +++ b/attachment_category/__manifest__.py @@ -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"], diff --git a/attachment_category/models/ir_attachment_category.py b/attachment_category/models/ir_attachment_category.py index 790e276e..dc48811c 100644 --- a/attachment_category/models/ir_attachment_category.py +++ b/attachment_category/models/ir_attachment_category.py @@ -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)]