mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-30 04:26:44 +00:00
Include template attachments in attachment count
This commit is contained in:
parent
d563e873ed
commit
2138977b07
@ -771,6 +771,21 @@ class Part(models.Model):
|
|||||||
|
|
||||||
return data.export(file_format)
|
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):
|
def attach_file(instance, filename):
|
||||||
""" Function for storing a file for a PartAttachment
|
""" Function for storing a file for a PartAttachment
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
</a></li>
|
</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<li{% ifequal tab 'attachments' %} class="active"{% endifequal %}>
|
<li{% ifequal tab 'attachments' %} class="active"{% endifequal %}>
|
||||||
<a href="{% url 'part-attachments' part.id %}">Attachments {% if part.attachments.all|length > 0 %}<span class="badge">{{ part.attachments.all|length }}</span>{% endif %}</a>
|
<a href="{% url 'part-attachments' part.id %}">Attachments {% if part.attachment_count > 0 %}<span class="badge">{{ part.attachment_count }}</span>{% endif %}</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user