Skip to content

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

Update fields with auto_now during save for order, product and payment

IKarbowiak1a4899132e8e
diff --git a/saleor/order/actions.py b/saleor/order/actions.py
index 7a21075973..5a7e0aee33 100644
--- a/saleor/order/actions.py
+++ b/saleor/order/actions.py
@@ -196,7 +196,7 @@ def mark_order_as_paid(order: "Order", request_user: "User"):
)
payment.charge_status = ChargeStatus.FULLY_CHARGED
payment.captured_amount = order.total.gross.amount
- payment.save(update_fields=["captured_amount", "charge_status"])
+ payment.save(update_fields=["captured_amount", "charge_status", "modified"])
events.order_manually_marked_as_paid_event(order=order, user=request_user)
manager = get_extensions_manager()
diff --git a/saleor/payment/utils.py b/saleor/payment/utils.py
index c9f0a3bb86..10703d0db1 100644
--- a/saleor/payment/utils.py
+++ b/saleor/payment/utils.py
@@ -201,17 +201,17 @@ def gateway_postprocess(transaction, payment):
if payment.get_charge_amount() <= 0:
payment.charge_status = ChargeStatus.FULLY_CHARGED
- payment.save(update_fields=["charge_status", "captured_amount"])
+ payment.save(update_fields=["charge_status", "captured_amount", "modified"])
order = payment.order
if order and order.is_fully_paid():
handle_fully_paid_order(order)
elif transaction_kind == TransactionKind.VOID:
payment.is_active = False
- payment.save(update_fields=["is_active"])
+ payment.save(update_fields=["is_active", "modified"])
elif transaction_kind == TransactionKind.REFUND:
- changed_fields = ["captured_amount"]
+ changed_fields = ["captured_amount", "modified"]
payment.captured_amount -= transaction.amount
payment.charge_status = ChargeStatus.PARTIALLY_REFUNDED
if payment.captured_amount <= 0:
@@ -252,7 +252,13 @@ def update_card_details(payment, gateway_response):
payment.cc_exp_year = gateway_response.card_info.exp_year
payment.cc_exp_month = gateway_response.card_info.exp_month
payment.save(
- update_fields=["cc_brand", "cc_last_digits", "cc_exp_year", "cc_exp_month"]
+ update_fields=[
+ "cc_brand",
+ "cc_last_digits",
+ "cc_exp_year",
+ "cc_exp_month",
+ "modified",
+ ]
)
diff --git a/saleor/product/utils/variant_prices.py b/saleor/product/utils/variant_prices.py
index b923f2925e..14038b2379 100644
--- a/saleor/product/utils/variant_prices.py
+++ b/saleor/product/utils/variant_prices.py
@@ -24,7 +24,7 @@ def update_product_minimal_variant_price(product, discounts=None, save=True):
if product.minimal_variant_price != minimal_variant_price:
product.minimal_variant_price_amount = minimal_variant_price.amount
if save:
- product.save(update_fields=["minimal_variant_price_amount"])
+ product.save(update_fields=["minimal_variant_price_amount", "updated_at"])
return product