Features: 1) Enhance __str__ in payments.models.Transaction to handle cases where balance is missing.
Fixes: 1) Adjust feedback creation logic in `core.models` to ensure it is only allowed when `order.status` is `FINISHED`. Extra: 1) Minor formatting adjustment in `payments.models.Transaction` for improved readability.
This commit is contained in:
parent
a4ec737334
commit
91ed79669b
2 changed files with 3 additions and 2 deletions
|
|
@ -1794,7 +1794,7 @@ class OrderProduct(ExportModelOperationsMixin("order_product"), NiceModel): # t
|
||||||
|
|
||||||
if action == "add":
|
if action == "add":
|
||||||
if not feedback_exists:
|
if not feedback_exists:
|
||||||
if self.order.status not in ["MOMENTAL", "PENDING", "FAILED"]:
|
if self.order.status == "FINISHED":
|
||||||
return Feedback.objects.create(rating=rating, comment=comment, order_product=self)
|
return Feedback.objects.create(rating=rating, comment=comment, order_product=self)
|
||||||
else:
|
else:
|
||||||
raise ValueError(_("you cannot feedback an order which is not received"))
|
raise ValueError(_("you cannot feedback an order which is not received"))
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,8 @@ class Transaction(NiceModel):
|
||||||
process = JSONField(verbose_name=_("processing details"), default=dict)
|
process = JSONField(verbose_name=_("processing details"), default=dict)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"{self.balance.user.email} | {self.amount}"
|
return f"{self.balance.user.email} | {self.amount}" if self.balance else\
|
||||||
|
f"{self.order.attributes.get("customer_email")} | {self.amount}"
|
||||||
|
|
||||||
def save(self, **kwargs):
|
def save(self, **kwargs):
|
||||||
if self.amount != 0.0 and (
|
if self.amount != 0.0 and (
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue