2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-01 11:10:54 +00:00

Download PDF for labels

This commit is contained in:
Oliver Walters
2021-01-09 21:50:42 +11:00
parent bdc7367e29
commit e133fff03e
6 changed files with 96 additions and 34 deletions

View File

@ -32,6 +32,7 @@ from InvenTree import helpers
import common.models
import report.models
import label.models
from InvenTree.status_codes import StockStatus
from InvenTree.models import InvenTreeTree, InvenTreeAttachment
@ -1333,14 +1334,31 @@ class StockItem(MPTTModel):
return len(self.available_test_reports()) > 0
def available_labels(self):
"""
Return a list of Label objects which match this StockItem
"""
labels = []
item_query = StockItem.objects.filter(pk=self.pk)
for lbl in label.models.StockItemLabel.objects.filter(enabled=True):
filters = helpers.validateFilterString(lbl.filters)
if item_query.filter(**filters).exists():
labels.append(lbl)
return labels
@property
def has_labels(self):
"""
Return True if there are any label templates available for this stock item
"""
# TODO - Implement this
return True
return len(self.available_labels()) > 0
@receiver(pre_delete, sender=StockItem, dispatch_uid='stock_item_pre_delete_log')

View File

@ -403,12 +403,7 @@ $("#stock-test-report").click(function() {
});
$("#print-label").click(function() {
launchModalForm(
"{% url 'stock-item-label-select' item.id %}",
{
follow: true,
}
)
printStockItemLabels([{{ item.pk }}]);
});
$("#stock-duplicate").click(function() {