Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Drop fulfilmentCreate mutation

fowczrekb88df593c7f2
diff --git a/saleor/graphql/order/mutations/fulfillments.py b/saleor/graphql/order/mutations/fulfillments.py
index c5c745d0c4..89847f8a44 100644
--- a/saleor/graphql/order/mutations/fulfillments.py
+++ b/saleor/graphql/order/mutations/fulfillments.py
@@ -26,23 +26,6 @@ from ...warehouse.types import Warehouse
from ..types import OrderLine
-class FulfillmentLineInput(graphene.InputObjectType):
- order_line_id = graphene.ID(
- description="The ID of the order line.", name="orderLineId"
- )
- quantity = graphene.Int(description="The number of line item(s) to be fulfilled.")
-
-
-class FulfillmentCreateInput(graphene.InputObjectType):
- tracking_number = graphene.String(description="Fulfillment tracking number.")
- notify_customer = graphene.Boolean(
- description="If true, send an email notification to the customer."
- )
- lines = graphene.List(
- FulfillmentLineInput, required=True, description="Item line to be fulfilled."
- )
-
-
class OrderFulfillStockInput(graphene.InputObjectType):
quantity = graphene.Int(
description="The number of line item to be fulfilled from given warehouse."
@@ -302,110 +285,6 @@ class OrderFulfill(BaseMutation):
return OrderFulfill(fulfillments=fulfillments, order=order)
-class FulfillmentCreate(BaseMutation):
- fulfillment = graphene.Field(Fulfillment, description="A created fulfillment.")
- order = graphene.Field(Order, description="Fulfilled order.")
-
- class Arguments:
- order = graphene.ID(
- description="ID of the order to be fulfilled.", name="order"
- )
- input = FulfillmentCreateInput(
- required=True, description="Fields required to create an fulfillment."
- )
-
- class Meta:
- description = "Creates a new fulfillment for an order."
- permissions = (OrderPermissions.MANAGE_ORDERS,)
- error_type_class = OrderError
- error_type_field = "order_errors"
-
- @classmethod
- def clean_lines(cls, order_lines, quantities):
- for order_line, quantity in zip(order_lines, quantities):
- line_quantity_unfulfilled = order_line.quantity_unfulfilled
- if quantity > line_quantity_unfulfilled:
- msg = (
- "Only %(quantity)d item%(item_pluralize)s remaining "
- "to fulfill: %(order_line)s."
- ) % {
- "quantity": line_quantity_unfulfilled,
- "item_pluralize": pluralize(line_quantity_unfulfilled),
- "order_line": order_line,
- }
- raise ValidationError(
- {
- "order_line_id": ValidationError(
- msg, code=OrderErrorCode.FULFILL_ORDER_LINE
- )
- }
- )
-
- @classmethod
- def clean_input(cls, data):
- lines = data["lines"]
- quantities = [line["quantity"] for line in lines]
- lines_ids = [line["order_line_id"] for line in lines]
- order_lines = cls.get_nodes_or_error(
- lines_ids, field="lines", only_type=OrderLine
- )
-
- cls.clean_lines(order_lines, quantities)
-
- if sum(quantities) <= 0:
- raise ValidationError(
- {
- "lines": ValidationError(
- "Total quantity must be larger than 0.",
- code=OrderErrorCode.ZERO_QUANTITY,
- )
- }
- )
-
- data["order_lines"] = order_lines
- data["quantities"] = quantities
- return data
-
- @classmethod
- def save(cls, user, fulfillment, order, cleaned_input):
- fulfillment.save()
- order_lines = cleaned_input.get("order_lines")
- quantities = cleaned_input.get("quantities")
- fulfillment_lines = []
- for order_line, quantity in zip(order_lines, quantities):
- if quantity > 0:
- fulfill_order_line(order_line, quantity)
- if order_line.is_digital:
- order_line.variant.digital_content.urls.create(line=order_line)
- fulfillment_lines.append(
- models.FulfillmentLine(
- order_line=order_line,
- fulfillment=fulfillment,
- quantity=quantity,
- )
- )
-
- fulfillment.lines.bulk_create(fulfillment_lines)
- order_fulfilled(
- fulfillment,
- user,
- fulfillment_lines,
- cleaned_input.get("notify_customer", True),
- )
- return fulfillment
-
- @classmethod
- def perform_mutation(cls, _root, info, order, **data):
- order = cls.get_node_or_error(info, order, field="order", only_type=Order)
- data = data.get("input")
- fulfillment = models.Fulfillment(
- tracking_number=data.pop("tracking_number", None) or "", order=order
- )
- cleaned_input = cls.clean_input(data)
- fulfillment = cls.save(info.context.user, fulfillment, order, cleaned_input)
- return FulfillmentCreate(fulfillment=fulfillment, order=fulfillment.order)
-
-
class FulfillmentUpdateTracking(BaseMutation):
fulfillment = graphene.Field(
Fulfillment, description="A fulfillment with updated tracking."
diff --git a/saleor/graphql/order/schema.py b/saleor/graphql/order/schema.py
index b03864ba18..3abce46c9c 100644
--- a/saleor/graphql/order/schema.py
+++ b/saleor/graphql/order/schema.py
@@ -22,7 +22,6 @@ from .mutations.fulfillments import (
FulfillmentCancel,
FulfillmentClearMeta,
FulfillmentClearPrivateMeta,
- FulfillmentCreate,
FulfillmentUpdateMeta,
FulfillmentUpdatePrivateMeta,
FulfillmentUpdateTracking,
@@ -175,7 +174,6 @@ class OrderMutations(graphene.ObjectType):
)
order_fulfill = OrderFulfill.Field()
order_fulfillment_cancel = FulfillmentCancel.Field()
- order_fulfillment_create = FulfillmentCreate.Field()
order_fulfillment_update_tracking = FulfillmentUpdateTracking.Field()
order_fulfillment_clear_meta = FulfillmentClearMeta.Field(
deprecation_reason=(
diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphql
index c0d323da3b..e06cf937f0 100644
--- a/saleor/graphql/schema.graphql
+++ b/saleor/graphql/schema.graphql
@@ -1774,30 +1774,12 @@ type FulfillmentClearPrivateMeta {
fulfillment: Fulfillment
}
-type FulfillmentCreate {
- errors: [Error!]! @deprecated(reason: "Use typed errors with error codes. This field will be removed after 2020-07-31.")
- fulfillment: Fulfillment
- order: Order
- orderErrors: [OrderError!]!
-}
-
-input FulfillmentCreateInput {
- trackingNumber: String
- notifyCustomer: Boolean
- lines: [FulfillmentLineInput]!
-}
-
type FulfillmentLine implements Node {
id: ID!
quantity: Int!
orderLine: OrderLine
}
-input FulfillmentLineInput {
- orderLineId: ID
- quantity: Int
-}
-
enum FulfillmentStatus {
FULFILLED
CANCELED
@@ -2404,7 +2386,6 @@ type Mutation {
orderClearMeta(input: MetaPath!, token: UUID!): OrderClearMeta @deprecated(reason: "Use the `deleteMetadata` mutation instead. This field will be removed after 2020-07-31.")
orderFulfill(input: OrderFulfillInput!, order: ID): OrderFulfill
orderFulfillmentCancel(id: ID!, input: FulfillmentCancelInput!): FulfillmentCancel
- orderFulfillmentCreate(input: FulfillmentCreateInput!, order: ID): FulfillmentCreate
orderFulfillmentUpdateTracking(id: ID!, input: FulfillmentUpdateTrackingInput!): FulfillmentUpdateTracking
orderFulfillmentClearMeta(id: ID!, input: MetaPath!): FulfillmentClearMeta @deprecated(reason: "Use the `deleteMetadata` mutation instead. This field will be removed after 2020-07-31.")
orderFulfillmentClearPrivateMeta(id: ID!, input: MetaPath!): FulfillmentClearPrivateMeta @deprecated(reason: "Use the `deletePrivateMetadata` mutation instead. This field will be removed after 2020-07-31.")