diff options
| author | Rafi Zadanly <zadanlyr@gmail.com> | 2023-07-21 11:20:34 +0700 |
|---|---|---|
| committer | Rafi Zadanly <zadanlyr@gmail.com> | 2023-07-21 11:20:34 +0700 |
| commit | f58e8b41012f692b7995026b9869d7c07763b250 (patch) | |
| tree | 15fe25a290fdc5090035d4a96a72fd242180d8df | |
| parent | 8358754e6f258e1f3b9bf602ad45d9c83859b700 (diff) | |
Update voucher manufacture response
| -rw-r--r-- | indoteknik_api/controllers/api_v1/voucher.py | 4 | ||||
| -rw-r--r-- | indoteknik_custom/models/voucher.py | 9 |
2 files changed, 4 insertions, 9 deletions
diff --git a/indoteknik_api/controllers/api_v1/voucher.py b/indoteknik_api/controllers/api_v1/voucher.py index 96c52e1e..454961da 100644 --- a/indoteknik_api/controllers/api_v1/voucher.py +++ b/indoteknik_api/controllers/api_v1/voucher.py @@ -34,7 +34,7 @@ class Voucher(controller.Controller): can_apply = True difference_to_apply = 0 - manufacture_ids = [x['id'] for x in voucher['manufactures']] + manufacture_ids = voucher['manufacture_ids'] subtotal = 0 has_match_manufacture = False for product in products: @@ -42,7 +42,7 @@ class Voucher(controller.Controller): price_discount = product['price']['price_discount'] quantity = product['quantity'] manufacture_id = product['manufacture']['id'] or False - + if len(manufacture_ids) == 0 or manufacture_id in manufacture_ids: purchase_amt = price * quantity discount_amt = (price - price_discount) * quantity diff --git a/indoteknik_custom/models/voucher.py b/indoteknik_custom/models/voucher.py index 1cdf88c4..839a5d47 100644 --- a/indoteknik_custom/models/voucher.py +++ b/indoteknik_custom/models/voucher.py @@ -59,12 +59,6 @@ class Voucher(models.Model): ir_attachment = self.env['ir.attachment'] discount_type = self.discount_type max_discount_amount = self.max_discount_amount if discount_type == 'percentage' else 0 - manufactures = [] - for manufacture in self.manufacture_ids: - manufactures.append({ - 'id': manufacture.id, - 'name': manufacture.x_name, - }) data = { 'id': self.id, 'image': ir_attachment.api_image('voucher', 'image', self.id), @@ -76,7 +70,8 @@ class Voucher(models.Model): 'remaining_time': self._res_remaining_time(), 'min_purchase_amount': self.min_purchase_amount, 'max_discount_amount': max_discount_amount, - 'manufactures': manufactures + 'manufacture_names': ", ".join([x.x_name for x in self.manufacture_ids]), + 'manufacture_ids': [x.id for x in self.manufacture_ids] } return data |
