diff options
| author | AndriFP <andrifebriyadiputra@gmail.com> | 2025-04-23 09:01:21 +0700 |
|---|---|---|
| committer | AndriFP <andrifebriyadiputra@gmail.com> | 2025-04-23 09:01:21 +0700 |
| commit | 8334445b2946fc7383acb682ec5cde3598b8accc (patch) | |
| tree | b80d769f47786f2e3078d9126c1d3733bf5df6fe | |
| parent | 71e47cc88e250600c2975a114dd420f27fda36b3 (diff) | |
(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 |
