diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py index e5b035f856..c5da47b33e 100644 --- a/InvenTree/part/models.py +++ b/InvenTree/part/models.py @@ -1087,6 +1087,20 @@ class Part(MPTTModel): return n + @property + def part_attachments(self): + """ + Return *all* attachments for this part, + potentially including attachments for template parts + above this one. + """ + + ancestors = self.get_ancestors(include_self=True) + + attachments = PartAttachment.objects.filter(part__in=ancestors) + + return attachments + def sales_orders(self): """ Return a list of sales orders which reference this part """ diff --git a/InvenTree/part/templates/part/attachments.html b/InvenTree/part/templates/part/attachments.html index 049ef0cd7a..aa31cd3f32 100644 --- a/InvenTree/part/templates/part/attachments.html +++ b/InvenTree/part/templates/part/attachments.html @@ -9,7 +9,7 @@
-{% include "attachment_table.html" with attachments=part.attachments.all %} +{% include "attachment_table.html" with attachments=part.part_attachments %} {% endblock %}