diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py index f7b577ccea..8a5a9125f3 100644 --- a/InvenTree/part/models.py +++ b/InvenTree/part/models.py @@ -771,6 +771,21 @@ class Part(models.Model): return data.export(file_format) + @property + def attachment_count(self): + """ Count the number of attachments for this part. + If the part is a variant of a template part, + include the number of attachments for the template part. + + """ + + n = self.attachments.count() + + if self.variant_of: + n += self.variant_of.attachments.count() + + return n + def attach_file(instance, filename): """ Function for storing a file for a PartAttachment diff --git a/InvenTree/part/templates/part/tabs.html b/InvenTree/part/templates/part/tabs.html index 6dd4a0ab80..53a551f36c 100644 --- a/InvenTree/part/templates/part/tabs.html +++ b/InvenTree/part/templates/part/tabs.html @@ -40,7 +40,7 @@ {% endif %}