summaryrefslogtreecommitdiff
path: root/indoteknik_api/controllers/api_v1/cart.py
diff options
context:
space:
mode:
authorRafi Zadanly <zadanlyr@gmail.com>2023-07-18 16:38:29 +0700
committerRafi Zadanly <zadanlyr@gmail.com>2023-07-18 16:38:29 +0700
commitd966917a5ba95074b6773f49fcb2c3c924296029 (patch)
tree1522069c54c85dad7ec01ae9c16000034cde8878 /indoteknik_api/controllers/api_v1/cart.py
parente0102841e6e21c7b583f096914aa4ba1a28e1587 (diff)
Fix lost merge voucher with promotion program
Diffstat (limited to 'indoteknik_api/controllers/api_v1/cart.py')
-rw-r--r--indoteknik_api/controllers/api_v1/cart.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/indoteknik_api/controllers/api_v1/cart.py b/indoteknik_api/controllers/api_v1/cart.py
index 035a40b7..0265ec57 100644
--- a/indoteknik_api/controllers/api_v1/cart.py
+++ b/indoteknik_api/controllers/api_v1/cart.py
@@ -37,7 +37,8 @@ class Cart(controller.Controller):
product_id = int(kw.get('product_id', 0))
qty = int(kw.get('qty', 0))
is_selected = kw.get('selected', False)
- program_line_id = int(kw.get('program_line_id', False))
+ program_line_id = kw.get('program_line_id', False)
+ program_line_id = False if program_line_id == 'null' or not program_line_id else int(program_line_id)
if is_selected:
is_selected = True if is_selected == 'true' else False
@@ -46,18 +47,19 @@ class Cart(controller.Controller):
query = [('user_id', '=', user_id), ('product_id', '=', product_id)]
cart = request.env['website.user.cart'].search(query, limit=1)
result = {}
+ data_to_update = {
+ 'qty': qty,
+ 'is_selected': is_selected,
+ 'program_line_id': program_line_id
+ }
if cart:
- data_to_update = {'qty': qty, 'is_selected': is_selected}
- if program_line_id:
- data_to_update['program_line_id'] = program_line_id
cart.write(data_to_update)
result['id'] = cart.id
else:
create = request.env['website.user.cart'].create({
'user_id': user_id,
'product_id': product_id,
- 'qty': qty,
- 'is_selected': is_selected
+ **data_to_update
})
result['id'] = create.id