Refunds in state "done" should always have an execution date

This commit is contained in:
Raphael Michel
2023-12-12 14:20:43 +01:00
parent d4a32fd39d
commit 7f948bf263
2 changed files with 7 additions and 0 deletions

View File

@@ -2143,6 +2143,12 @@ class OrderRefund(models.Model):
self.local_id = (self.order.refunds.aggregate(m=Max('local_id'))['m'] or 0) + 1
if 'update_fields' in kwargs:
kwargs['update_fields'] = {'local_id'}.union(kwargs['update_fields'])
if self.state == OrderRefund.REFUND_STATE_DONE and not self.execution_date:
self.execution_date = now()
if 'update_fields' in kwargs:
kwargs['update_fields'] = {'execution_date'}.union(kwargs['update_fields'])
super().save(*args, **kwargs)