Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add prefetch for fulfillment webhook
Maciej Korycinski709809a664d7
diff --git a/saleor/webhook/payloads.py b/saleor/webhook/payloads.pyindex 8de270bd13..b0426b3985 100644--- a/saleor/webhook/payloads.py+++ b/saleor/webhook/payloads.py@@ -11,7 +11,7 @@ from ..core.utils.anonymization import (generate_fake_user,)from ..order import FulfillmentStatus, OrderStatus-from ..order.models import Fulfillment, Order+from ..order.models import Fulfillment, FulfillmentLine, Orderfrom ..order.utils import get_order_countryfrom ..payment import ChargeStatusfrom ..product.models import Product@@ -212,13 +212,16 @@ def generate_product_payload(product: "Product"):def generate_fulfillment_lines_payload(fulfillment: Fulfillment):serializer = PayloadSerializer()+ lines = FulfillmentLine.objects.prefetch_related(+ "order_line__variant__product__product_type"+ ).filter(fulfillment=fulfillment)line_fields = ("quantity",)-return serializer.serialize(- fulfillment,+ lines,fields=line_fields,extra_dict_data={- "weight": (lambda fl: fl.order_line.variant.get_weight().oz),+ "weight": (lambda fl: fl.order_line.variant.get_weight().g),+ "weight_unit": "grams","product_type": (lambda fl: fl.order_line.variant.product.product_type.name),