diff --git a/InvenTree/stock/templates/stock/item_base.html b/InvenTree/stock/templates/stock/item_base.html index db9c4417d5..8a1388e636 100644 --- a/InvenTree/stock/templates/stock/item_base.html +++ b/InvenTree/stock/templates/stock/item_base.html @@ -80,6 +80,7 @@ <li><a class='dropdown-item' href='#' id='stock-count' title='{% trans "Count stock" %}'><span class='fas fa-check-circle icon-green'></span> {% trans "Count stock" %}</a></li> {% if not item.customer %} <li><a class='dropdown-item' href='#' id='stock-add' title='{% trans "Add stock" %}'><span class='fas fa-plus-circle icon-green'></span> {% trans "Add stock" %}</a></li> + <li><a class='dropdown-item' href='#' id='stock-remove' title='{% trans "Remove stock" %}'><span class='fas fa-minus-circle icon-red'></span> {% trans "Remove stock" %}</a></li> {% endif %} {% if item.part.trackable %} <li><a class='dropdown-item' href='#' id='stock-serialize' title='{% trans "Serialize stock" %}'><span class='fas fa-hashtag'></span> {% trans "Serialize stock" %}</a> </li> diff --git a/InvenTree/stock/test_views.py b/InvenTree/stock/test_views.py index f54b188dcd..acf1626136 100644 --- a/InvenTree/stock/test_views.py +++ b/InvenTree/stock/test_views.py @@ -31,6 +31,57 @@ class StockListTest(StockViewTestCase): self.assertEqual(response.status_code, 200) +class StockDetailTest(StockViewTestCase): + """Unit test for the 'stock detail' page""" + + def test_basic_info(self): + """Test that basic stock item info is rendered""" + + url = reverse('stock-item-detail', kwargs={'pk': 1}) + + response = self.client.get(url) + self.assertEqual(response.status_code, 200) + + html = str(response.content) + + # Part name + self.assertIn('Stock Item: M2x4 LPHS', html) + + # Quantity + self.assertIn('<h5>Available Quantity</h5>', html) + self.assertIn('<h5>4000 </h5>', html) + + # Batch code + self.assertIn('Batch', html) + self.assertIn('<td>B123</td>', html) + + # Actions to check + actions = [ + "id=\\\'stock-count\\\' title=\\\'Count stock\\\'", + "id=\\\'stock-add\\\' title=\\\'Add stock\\\'", + "id=\\\'stock-remove\\\' title=\\\'Remove stock\\\'", + "id=\\\'stock-move\\\' title=\\\'Transfer stock\\\'", + "id=\\\'stock-duplicate\\\'", + "id=\\\'stock-edit\\\'", + "id=\\\'stock-delete\\\'", + ] + + # Initially we should not have any of the required permissions + for act in actions: + self.assertNotIn(act, html) + + # Give the user all the permissions + self.assignRole('stock.add') + self.assignRole('stock.change') + self.assignRole('stock.delete') + + response = self.client.get(url) + html = str(response.content) + + for act in actions: + self.assertIn(act, html) + + class StockOwnershipTest(StockViewTestCase): """Tests for stock ownership views."""