mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Merge pull request #1462 from eeintech/stock_label
Added revision and stock item QR code URL for label creation
This commit is contained in:
commit
3e6429cb13
@ -280,11 +280,25 @@ def MakeBarcode(object_name, object_pk, object_data={}, **kwargs):
|
||||
json string of the supplied data plus some other data
|
||||
"""
|
||||
|
||||
url = kwargs.get('url', False)
|
||||
brief = kwargs.get('brief', True)
|
||||
|
||||
data = {}
|
||||
|
||||
if brief:
|
||||
if url:
|
||||
request = object_data.get('request', None)
|
||||
item_url = object_data.get('item_url', None)
|
||||
absolute_url = None
|
||||
|
||||
if request and item_url:
|
||||
absolute_url = request.build_absolute_uri(item_url)
|
||||
# Return URL (No JSON)
|
||||
return absolute_url
|
||||
|
||||
if item_url:
|
||||
# Return URL (No JSON)
|
||||
return item_url
|
||||
elif brief:
|
||||
data[object_name] = object_pk
|
||||
else:
|
||||
data['tool'] = 'InvenTree'
|
||||
|
@ -253,10 +253,12 @@ class StockItemLabel(LabelTemplate):
|
||||
'part': stock_item.part,
|
||||
'name': stock_item.part.full_name,
|
||||
'ipn': stock_item.part.IPN,
|
||||
'revision': stock_item.part.revision,
|
||||
'quantity': normalize(stock_item.quantity),
|
||||
'serial': stock_item.serial,
|
||||
'uid': stock_item.uid,
|
||||
'qr_data': stock_item.format_barcode(brief=True),
|
||||
'qr_url': stock_item.format_barcode(url=True, request=request),
|
||||
'tests': stock_item.testResultMap()
|
||||
}
|
||||
|
||||
|
@ -344,6 +344,8 @@ class StockItem(MPTTModel):
|
||||
"stockitem",
|
||||
self.id,
|
||||
{
|
||||
"request": kwargs.get('request', None),
|
||||
"item_url": reverse('stock-item-detail', kwargs={'pk': self.id}),
|
||||
"url": reverse('api-stock-detail', kwargs={'pk': self.id}),
|
||||
},
|
||||
**kwargs
|
||||
|
Loading…
Reference in New Issue
Block a user