diff --git a/InvenTree/InvenTree/static/script/inventree/barcode.js b/InvenTree/InvenTree/static/script/inventree/barcode.js index f623a6e886..d4c87f361e 100644 --- a/InvenTree/InvenTree/static/script/inventree/barcode.js +++ b/InvenTree/InvenTree/static/script/inventree/barcode.js @@ -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 */ diff --git a/InvenTree/stock/templates/stock/item_base.html b/InvenTree/stock/templates/stock/item_base.html index f6dcf82f88..837509c975 100644 --- a/InvenTree/stock/templates/stock/item_base.html +++ b/InvenTree/stock/templates/stock/item_base.html @@ -80,6 +80,9 @@ InvenTree | {% trans "Stock Item" %} - {{ item }}
  • {% trans "Show QR Code" %}
  • {% trans "Print Label" %}
  • {% trans "Link Barcode" %}
  • + {% if item.uid %} +
  • {% trans "Unlink Barcode" %}
  • + {% endif %} {% 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 %}