summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafi Zadanly <zadanlyr@gmail.com>2023-07-10 15:28:00 +0700
committerRafi Zadanly <zadanlyr@gmail.com>2023-07-10 15:28:00 +0700
commit30ee32fcb482d325dd4a8db09983112a81fdb448 (patch)
tree361e2d592b9faf7f4031fc265afcc2952d3d90a2
parent8ae3fbf012539d286a5de3deb3d7c500920c2257 (diff)
Update format voucher api response
-rw-r--r--indoteknik_custom/models/voucher.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/indoteknik_custom/models/voucher.py b/indoteknik_custom/models/voucher.py
index c97e54fa..e1497d9a 100644
--- a/indoteknik_custom/models/voucher.py
+++ b/indoteknik_custom/models/voucher.py
@@ -42,6 +42,8 @@ class Voucher(models.Model):
def format(self):
ir_attachment = self.env['ir.attachment']
+ discount_type = self.discount_type
+ max_discount_amount = self.max_discount_amount if discount_type == 'percentage' else 0
data = {
'id': self.id,
'image': ir_attachment.api_image('voucher', 'image', self.id),
@@ -49,9 +51,10 @@ class Voucher(models.Model):
'code': self.code,
'description': self.description,
'discount_amount': self.discount_amount,
- 'discount_type': self.discount_type,
+ 'discount_type': discount_type,
'remaining_time': self.end_time.strftime('%d-%m-%Y'),
- 'min_purchase_amount': self.min_purchase_amount
+ 'min_purchase_amount': self.min_purchase_amount,
+ 'max_discount_amount': max_discount_amount,
}
return data