Repository: inventree/inventree
Issue: [BUG] App QR scanner fails with server version 0.6

**Describe the bug**


Barcode / QR code scanner in iPhone App does not work. App version 0.5.6 and Inventree version 0.6.1

**Steps to Reproduce**

Steps to reproduce the behavior:

1. Installed a fresh docker version of 0.6.1. 
2. Added a part category and a single new part and displayed the QR code for that part.
3. Opened the iPhone App (version 0.5.6), connected to server.
4. Scan barcode within the app5. 
5. App fails with "No match for barcode" message


**Expected behavior**

Expected to open the part in the App as it worked in 0.5.4 of Inventree with the App.

The App fails with the message "No match for barcode"

inventree-proxy log contains message  "POST /api/barcode/ HTTP/1.1" 200 130 "-" "Dart/2.13 (dart:io)" "-"  

**Deployment Method**
- [x ] Docker
- [ ] Bare Metal

**Version Information**

App version 0.5.6 and Inventree version 0.6.1

Changed files:
InvenTree/barcodes/plugins/inventree_barcode.py, InvenTree/barcodes/api.py, InvenTree/barcodes/tests.py

diff --git a/InvenTree/barcodes/api.py b/InvenTree/barcodes/api.py
index 0d3656ce4..047db357a 100644
--- a/InvenTree/barcodes/api.py
+++ b/InvenTree/barcodes/api.py
@@ -12,6 +12,7 @@ from rest_framework.views import APIView
 from stock.models import StockItem
 from stock.serializers import StockItemSerializer
 
+from barcodes.plugins.inventree_barcode import InvenTreeBarcodePlugin
 from barcodes.barcode import hash_barcode
 from plugin import registry
 
@@ -57,6 +58,9 @@ class BarcodeScan(APIView):
 
         barcode_data = data.get('barcode')
 
+        # Ensure that the default barcode handler is installed
+        plugins.append(InvenTreeBarcodePlugin())
+
         # Look for a barcode plugin which knows how to deal with this barcode
         plugin = None
 
diff --git a/InvenTree/barcodes/plugins/inventree_barcode.py b/InvenTree/barcodes/plugins/inventree_barcode.py
index 842f9029a..1b451f028 100644
--- a/InvenTree/barcodes/plugins/inventree_barcode.py
+++ b/InvenTree/barcodes/plugins/inventree_barcode.py
@@ -52,7 +52,7 @@ class InvenTreeBarcodePlugin(BarcodePlugin):
         # If any of the following keys are in the JSON data,
         # let's go ahead and assume that the code is a valid InvenTree one...
 
-        for key in ['tool', 'version', 'InvenTree', 'stockitem', 'location', 'part']:
+        for key in ['tool', 'version', 'InvenTree', 'stockitem', 'stocklocation', 'part']:
             if key in self.data.keys():
                 return True
 
diff --git a/InvenTree/barcodes/tests.py b/InvenTree/barcodes/tests.py
index a9795c392..c9a063e8f 100644
--- a/InvenTree/barcodes/tests.py
+++ b/InvenTree/barcodes/tests.py
@@ -56,6 +56,66 @@ class BarcodeAPITest(APITestCase):
         self.assertIn('plugin', data)
         self.assertIsNone(data['plugin'])
 
+    def test_find_part(self):
+        """
+        Test that we can lookup a part based on ID
+        """
+
+        response = self.client.post(
+            self.scan_url,
+            {
+                'barcode': {
+                    'part': 1,
+                },
+            },
+            format='json',
+        )
+
+        self.assertEqual(response.status_code, status.HTTP_200_OK)
+        self.assertIn('part', response.data)
+        self.assertIn('barcode_data', response.data)
+        self.assertEqual(response.data['part']['pk'], 1)
+
+    def test_find_stock_item(self):
+        """
+        Test that we can lookup a stock item based on ID
+        """
+
+        response = self.client.post(
+            self.scan_url,
+            {
+                'barcode': {
+                    'stockitem': 1,
+                }
+            },
+            format='json',
+        )
+
+        self.assertEqual(response.status_code, status.HTTP_200_OK)
+        self.assertIn('stockitem', response.data)
+        self.assertIn('barcode_data', response.data)
+        self.assertEqual(response.data['stockitem']['pk'], 1)
+
+    def test_find_location(self):
+        """
+        Test that we can lookup a stock location based on ID
+        """
+
+        response = self.client.post(
+            self.scan_url,
+            {
+                'barcode': {
+                    'stocklocation': 1,
+                },
+            },
+            format='json'
+        )
+
+        self.assertEqual(response.status_code, status.HTTP_200_OK)
+        self.assertIn('stocklocation', response.data)
+        self.assertIn('barcode_data', response.data)
+        self.assertEqual(response.data['stocklocation']['pk'], 1)
+
     def test_integer_barcode(self):
 
         response = self.postBarcode(self.scan_url, '123456789')