From 60c249c150dd7dc1ac33230cc37cf6387f1159f8 Mon Sep 17 00:00:00 2001 From: Denis Roussel Date: Sun, 18 Oct 2020 15:18:47 +0200 Subject: [PATCH] [14.0][MIG] attachment_category --- attachment_category/__manifest__.py | 2 +- attachment_category/models/ir_attachment_category.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) 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)]