Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Update fields with auto_now during save for order, product and payment
IKarbowiak1a4899132e8e
diff --git a/saleor/order/actions.py b/saleor/order/actions.pyindex 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_CHARGEDpayment.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.pyindex 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.orderif 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.amountpayment.charge_status = ChargeStatus.PARTIALLY_REFUNDEDif payment.captured_amount <= 0:@@ -252,7 +252,13 @@ def update_card_details(payment, gateway_response):payment.cc_exp_year = gateway_response.card_info.exp_yearpayment.cc_exp_month = gateway_response.card_info.exp_monthpayment.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.pyindex 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.amountif save:- product.save(update_fields=["minimal_variant_price_amount"])+ product.save(update_fields=["minimal_variant_price_amount", "updated_at"])return product