Skip to content

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

Update fields instead saving object

Krzysztof Świątekf7ab9afd2886
diff --git a/saleor/graphql/translations/schema.py b/saleor/graphql/translations/schema.py
index a815d4887f..7ac99d8f18 100644
--- a/saleor/graphql/translations/schema.py
+++ b/saleor/graphql/translations/schema.py
@@ -104,7 +104,9 @@ class TranslationQueries(graphene.ObjectType):
graphene.ID, description="ID of the object to retrieve.", required=True
),
kind=graphene.Argument(
- TranslatableKinds, required=True, description="Kind of the object to retrieve."
+ TranslatableKinds,
+ required=True,
+ description="Kind of the object to retrieve.",
),
)
diff --git a/saleor/order/utils.py b/saleor/order/utils.py
index 4a8c2d3b28..6a83a7eae1 100644
--- a/saleor/order/utils.py
+++ b/saleor/order/utils.py
@@ -99,7 +99,14 @@ def recalculate_order(order: Order, **kwargs):
if order.discount:
total -= order.discount
order.total = total
- order.save()
+ order.save(
+ update_fields=[
+ "discount_amount",
+ "total_net_amount",
+ "total_gross_amount",
+ "currency",
+ ]
+ )
recalculate_order_weight(order)
@@ -138,7 +145,13 @@ def update_order_prices(order, discounts):
if order.shipping_method:
order.shipping_price = manager.calculate_order_shipping(order)
- order.save()
+ order.save(
+ update_fields=[
+ "shipping_price_net_amount",
+ "shipping_price_gross_amount",
+ "currency",
+ ]
+ )
recalculate_order(order)