mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Part: add function to get part attachments for *all* parents of a part
This commit is contained in:
parent
35cd3923a5
commit
cd8214ff4a
@ -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 """
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
<hr>
|
||||
|
||||
{% include "attachment_table.html" with attachments=part.attachments.all %}
|
||||
{% include "attachment_table.html" with attachments=part.part_attachments %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user