summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2024-08-06 08:56:22 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2024-08-06 08:56:22 +0700
commit9318594b9f575ebd944056d84c48ce4e5507eece (patch)
treefe03052c9f460c1bfa775b49921acebca914f5f2
parent350014811b8776042afc0942223c0281b8ff3976 (diff)
cr voucher shipping
-rw-r--r--indoteknik_api/controllers/api_v1/voucher.py5
-rw-r--r--indoteknik_custom/models/voucher.py1
2 files changed, 6 insertions, 0 deletions
diff --git a/indoteknik_api/controllers/api_v1/voucher.py b/indoteknik_api/controllers/api_v1/voucher.py
index 53f118ec..cd5dff20 100644
--- a/indoteknik_api/controllers/api_v1/voucher.py
+++ b/indoteknik_api/controllers/api_v1/voucher.py
@@ -20,6 +20,7 @@ class Voucher(controller.Controller):
def get_vouchers_by_user_id(self, **kw):
cart = request.env['website.user.cart']
code = kw.get('code')
+ type = kw.get('type')
user_id = int(kw.get('user_id', 0))
source = kw.get('source')
visibility = ['public']
@@ -32,6 +33,10 @@ class Voucher(controller.Controller):
if user_pricelist:
domain += [('excl_pricelist_ids', 'not in', [user_pricelist.id])]
+ if type:
+ type = type.split(',')
+ domain += [('apply_type', 'in', type)]
+
domain += [('visibility', 'in', visibility)]
vouchers = request.env['voucher'].get_active_voucher(domain)
checkout = cart.get_user_checkout(user_id, source=source)
diff --git a/indoteknik_custom/models/voucher.py b/indoteknik_custom/models/voucher.py
index 66f763e0..c21ef209 100644
--- a/indoteknik_custom/models/voucher.py
+++ b/indoteknik_custom/models/voucher.py
@@ -90,6 +90,7 @@ class Voucher(models.Model):
'image': ir_attachment.api_image('voucher', 'image', self.id),
'name': self.name,
'code': self.code,
+ 'apply_type': self.apply_type,
'description': self.description,
'remaining_time': self._res_remaining_time(),
}