diff options
| author | IT Fixcomart <it@fixcomart.co.id> | 2025-04-23 07:32:25 +0000 |
|---|---|---|
| committer | IT Fixcomart <it@fixcomart.co.id> | 2025-04-23 07:32:25 +0000 |
| commit | 00e6c40d7432a760123b6f6b23561e7d06cdd525 (patch) | |
| tree | c7bbba7d3692ab1d5594166cf24780078b873693 | |
| parent | 0a38cfc08803b16e8579860273f9192f9f3ed33c (diff) | |
| parent | 8334445b2946fc7383acb682ec5cde3598b8accc (diff) | |
Merged in voucher-duplicate (pull request #278)
(miqdad) fix duplicate voucher
| -rw-r--r-- | indoteknik_custom/models/voucher.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/indoteknik_custom/models/voucher.py b/indoteknik_custom/models/voucher.py index 101d4bcf..7b458d01 100644 --- a/indoteknik_custom/models/voucher.py +++ b/indoteknik_custom/models/voucher.py @@ -265,3 +265,19 @@ class Voucher(models.Model): tnc.append(f'<li>{line_tnc}</li>') return ' '.join(tnc) + # copy semua data kalau diduplicate + def copy(self, default=None): + default = dict(default or {}) + voucher_lines = [] + + for line in self.voucher_line: + voucher_lines.append((0, 0, { + 'manufacture_id': line.manufacture_id.id, + 'discount_amount': line.discount_amount, + 'discount_type': line.discount_type, + 'min_purchase_amount': line.min_purchase_amount, + 'max_discount_amount': line.max_discount_amount, + })) + + default['voucher_line'] = voucher_lines + return super(Voucher, self).copy(default)
\ No newline at end of file |
