Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Decrease quantity on order line fulfillment
Anna Siwikdc07e64e6790
diff --git a/saleor/dashboard/order/forms.py b/saleor/dashboard/order/forms.pyindex 72f5b5da83..72e54f5dce 100644--- a/saleor/dashboard/order/forms.py+++ b/saleor/dashboard/order/forms.py@@ -353,3 +353,7 @@ class FulfillmentLineForm(forms.ModelForm):'Fulfill order line form error','Order line could not be fulfilled with zero quantity.'))return quantity++ def save(self, commit=True):+ fulfill_order_line(self.instance.order_line, self.instance.quantity)+ return super().save(commit)diff --git a/saleor/dashboard/order/utils.py b/saleor/dashboard/order/utils.pyindex 3f0aff5fc6..bb1ea087e0 100644--- a/saleor/dashboard/order/utils.py+++ b/saleor/dashboard/order/utils.py@@ -39,7 +39,6 @@ def create_packing_slip_pdf(order, absolute_url):return pdf_file, order-def fulfill_order_line(order_line, quantity, fulfillment):+def fulfill_order_line(order_line, quantity):"""Fulfill order line with given quantity."""decrease_stock(order_line.stock, quantity)- return fulfillment.lines.create(order_line=order_line, quantity=quantity)diff --git a/tests/dashboard/test_order.py b/tests/dashboard/test_order.pyindex 19b3720241..31c5091f86 100644--- a/tests/dashboard/test_order.py+++ b/tests/dashboard/test_order.py@@ -473,10 +473,9 @@ def test_note_form_sent_email(def test_fulfill_order_line(order_with_lines_and_stock):order = order_with_lines_and_stock- fulfillment = Fulfillment.objects.create(order=order)line = order.lines.first()stock = line.stockstock_quantity_after = stock.quantity - line.quantity- fulfill_order_line(line, line.quantity, fulfillment)+ fulfill_order_line(line, line.quantity)stock.refresh_from_db()assert stock.quantity == stock_quantity_after