Features: 1) Introduce conditional check ensuring instance.finalize() execution only when no order product errors exist;
Fixes: 1) Prevent potential incorrect execution of `instance.finalize()` by adding else block; Extra: 1) Add spacing for improved readability; 2) Minor formatting tweaks in signal logic.
This commit is contained in:
parent
82667216f2
commit
be76a3bb8d
1 changed files with 4 additions and 1 deletions
|
|
@ -80,9 +80,11 @@ def process_order_changes(instance, created, **kwargs):
|
|||
if instance.status == "CREATED":
|
||||
if not instance.is_whole_digital:
|
||||
send_order_created_email.delay(instance.uuid)
|
||||
|
||||
for order_product in instance.order_products.filter(status="DELIVERING"):
|
||||
if not order_product.product.is_digital:
|
||||
continue
|
||||
|
||||
try:
|
||||
vendor_name = (
|
||||
order_product.product.stocks.filter(price=order_product.buy_price).first().vendor.name.lower()
|
||||
|
|
@ -95,6 +97,7 @@ def process_order_changes(instance, created, **kwargs):
|
|||
except Exception as e:
|
||||
order_product.add_error(f"Failed to buy {order_product.uuid}. Reason: {e}...")
|
||||
|
||||
else:
|
||||
instance.finalize()
|
||||
|
||||
if instance.order_products.filter(status="FAILED").count() == instance.order_products.count():
|
||||
|
|
|
|||
Loading…
Reference in a new issue