Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Merge branch 'master' into feature/gift-cards-mvp
IKarbowiakcd2360555840
diff --cc saleor/graphql/order/mutations/fulfillments.pyindex b30d749666,6049d81322..04eaa8b23c--- a/saleor/graphql/order/mutations/fulfillments.py+++ b/saleor/graphql/order/mutations/fulfillments.py@@@ -95,23 -92,11 +95,11 @@@ class OrderFulfill(BaseMutation)@classmethoddef clean_lines(cls, order_lines, quantities):- for order_line, line_quantities in zip(order_lines, quantities):-+ for order_line in order_lines:+ line_total_quantity = quantities[order_line.pk]- quantity_awaiting = sum(- [- f_line.quantity- if f_line.fulfillment.status- == FulfillmentStatus.WAITING_FOR_APPROVAL- else 0- for f_line in order_line.fulfillment_lines.all()- ]- )-- line_quantity_unfulfilled = (- order_line.quantity_unfulfilled - quantity_awaiting- )+ line_quantity_unfulfilled = order_line.quantity_unfulfilled- if sum(line_quantities) > line_quantity_unfulfilled:+ if line_total_quantity > line_quantity_unfulfilled:msg = ("Only %(quantity)d item%(item_pluralize)s remaining ""to fulfill: %(order_line)s."@@@ -205,19 -190,10 +193,14 @@@lines_ids = [line["order_line_id"] for line in lines]cls.check_lines_for_duplicates(lines_ids)order_lines = cls.get_nodes_or_error(- lines_ids,- field="lines",- only_type=OrderLine,- qs=order_models.OrderLine.objects.prefetch_related(- "fulfillment_lines__fulfillment"- ),+ lines_ids, field="lines", only_type=OrderLine)+ order_line_id_to_total_quantity = {+ order_line.pk: sum(line_quantities)+ for order_line, line_quantities in zip(order_lines, quantities_for_lines)+ }- cls.clean_lines(order_lines, quantities_for_lines)+ cls.clean_lines(order_lines, order_line_id_to_total_quantity)cls.check_total_quantity_of_items(quantities_for_lines)diff --cc saleor/graphql/product/tests/benchmark/test_product.pyindex 4aa3f3c4c1,f5a0284661..90fc480566--- a/saleor/graphql/product/tests/benchmark/test_product.py+++ b/saleor/graphql/product/tests/benchmark/test_product.py@@@ -639,24 -670,7 +639,24 @@@ def test_filter_products_by_boolean_att]},}- get_graphql_content(api_client.post_graphql(query, variables))+ get_graphql_content(api_client.post_graphql(QUERY_PRODUCTS_WITH_FILTER, variables))++[email protected]_queries(autouse=False)+def test_filter_products_by_gift_card(+ staff_api_client,+ product_list,+ boolean_attribute,+ channel_USD,+ count_queries,+ shippable_gift_card_product,+):- variables = {"filter": {"giftCard": True}}++ variables = {"channel": channel_USD.slug, "filter": {"giftCard": True}}++ get_graphql_content(+ staff_api_client.post_graphql(QUERY_PRODUCTS_WITH_FILTER, variables)+ )@pytest.mark.django_db