mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-01 11:10:54 +00:00
Add bulk delete for purchase order line items (#4452)
* add bulk delete for purchase order line items * bump API version * fix JS style * handle parts with no linked manufacturer part correctly * add unit test for purchase order line item bulk delete
This commit is contained in:
@ -495,7 +495,7 @@ class PurchaseOrderLineItemFilter(rest_filters.FilterSet):
|
||||
return queryset
|
||||
|
||||
|
||||
class PurchaseOrderLineItemList(APIDownloadMixin, ListCreateAPI):
|
||||
class PurchaseOrderLineItemList(APIDownloadMixin, ListCreateDestroyAPIView):
|
||||
"""API endpoint for accessing a list of PurchaseOrderLineItem objects.
|
||||
|
||||
- GET: Return a list of PurchaseOrder Line Item objects
|
||||
|
@ -38,6 +38,22 @@
|
||||
</div>
|
||||
<div class='panel-content'>
|
||||
<div id='order-toolbar-buttons' class='btn-group' style='float: right;'>
|
||||
{% if roles.purchase_order.change %}
|
||||
{% if order.is_pending or allow_extra_editing %}
|
||||
<div class='btn-group' role='group'>
|
||||
<!-- Multiple-select actions -->
|
||||
<button id='multi-select-options' class='btn btn-primary dropdown-toggle' data-bs-toggle='dropdown'>
|
||||
<span class='fas fa-tools'></span> <span class='caret'></span>
|
||||
</button>
|
||||
<ul class='dropdown-menu'>
|
||||
<li><a class='dropdown-item' href='#' id='po-lines-bulk-delete' title='{% trans "Delete Line Items" %}'>
|
||||
<span class='fas fa-trash-alt icon-red'></span> {% trans "Delete Line Items" %}
|
||||
</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% include "filter_list.html" with id="purchase-order-lines" %}
|
||||
</div>
|
||||
|
||||
|
@ -603,6 +603,26 @@ class PurchaseOrderLineItemTest(OrderTest):
|
||||
self.filter({'has_pricing': 1}, 0)
|
||||
self.filter({'has_pricing': 0}, 5)
|
||||
|
||||
def test_po_line_bulk_delete(self):
|
||||
"""Test that we can bulk delete multiple PurchaseOrderLineItems via the API."""
|
||||
n = models.PurchaseOrderLineItem.objects.count()
|
||||
|
||||
self.assignRole('purchase_order.delete')
|
||||
|
||||
url = reverse('api-po-line-list')
|
||||
|
||||
# Try to delete a set of line items via their IDs
|
||||
self.delete(
|
||||
url,
|
||||
{
|
||||
'items': [1, 2],
|
||||
},
|
||||
expected_code=204,
|
||||
)
|
||||
|
||||
# We should have 2 less PurchaseOrderLineItems after deletign them
|
||||
self.assertEqual(models.PurchaseOrderLineItem.objects.count(), n - 2)
|
||||
|
||||
|
||||
class PurchaseOrderDownloadTest(OrderTest):
|
||||
"""Unit tests for downloading PurchaseOrder data via the API endpoint."""
|
||||
|
Reference in New Issue
Block a user