From 135fc6e26d381853b6317ada8b978303367e07a1 Mon Sep 17 00:00:00 2001 From: fureunoir Date: Tue, 6 Jan 2026 10:20:49 +0300 Subject: [PATCH] Features: 1) Add validation to `return_balance_back` to skip execution if status is already "RETURNED"; 2) Raise `NotImplementedError` when attempting to process a return without an associated user. Fixes: None; Extra: None; --- engine/core/models.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/engine/core/models.py b/engine/core/models.py index 668e741d..46065a5a 100644 --- a/engine/core/models.py +++ b/engine/core/models.py @@ -1937,8 +1937,12 @@ class OrderProduct(ExportModelOperationsMixin("order_product"), NiceModel): ] def return_balance_back(self): + if self.status == "RETURNED": + return self.status = "RETURNED" self.save() + if not self.order.user: + raise NotImplementedError self.order.user.payments_balance.amount += self.buy_price self.order.user.payments_balance.save()