Add function to un-link barcode from a stock item

This commit is contained in:
Oliver Walters 2020-06-12 10:12:31 +10:00
parent beccbe8583
commit ba94b340dd
2 changed files with 37 additions and 0 deletions

View File

@ -22,6 +22,36 @@ function scanBarcode(barcode, options={}) {
}
function unlinkBarcode(stockitem) {
/*
* Remove barcode association from a device.
*/
showQuestionDialog(
"Unlink Barcode",
"Remove barcode association from this Stock Item",
{
accept_text: "Unlink",
accept: function() {
inventreePut(
`/api/stock/${stockitem}/`,
{
// Clear the UID field
uid: '',
},
{
method: 'PATCH',
success: function(response, status) {
location.reload();
},
},
);
},
}
);
}
/*
* Associate barcode data with a StockItem
*/

View File

@ -80,6 +80,9 @@ InvenTree | {% trans "Stock Item" %} - {{ item }}
<li><a href='#' id='show-qr-code'><span class='fas fa-qrcode'></span> {% trans "Show QR Code" %}</a></li>
<li><a href='#' id='print-label'><span class='fas fa-tag'></span> {% trans "Print Label" %}</a></li>
<li><a href='#' id='link-barcode'><span class='fas fa-link'></span> {% trans "Link Barcode" %}</a></li>
{% if item.uid %}
<li><a href='#' id='unlink-barcode'><span class='fas fa-unlink'></span> {% trans "Unlink Barcode" %}</a></li>
{% endif %}
</ul>
</div>
{% if item.in_stock %}
@ -335,6 +338,10 @@ $("#show-qr-code").click(function() {
});
});
$("#unlink-barcode").click(function() {
unlinkBarcode({{ item.id }});
});
{% if item.in_stock %}
{% if item.part.salable %}