diff options
| author | Rafi Zadanly <zadanlyr@gmail.com> | 2023-07-26 09:38:27 +0700 |
|---|---|---|
| committer | Rafi Zadanly <zadanlyr@gmail.com> | 2023-07-26 09:38:27 +0700 |
| commit | c765b6ccc3da5051d7cb8e3997012fa6f46dd1f8 (patch) | |
| tree | 09d561db9c0024b6bd9d791decceac993152c076 /indoteknik_api/controllers/api_v1 | |
| parent | d454b715e7c7c31836cd525d9470b0eb3b1e7376 (diff) | |
Add source field on cart
Diffstat (limited to 'indoteknik_api/controllers/api_v1')
| -rw-r--r-- | indoteknik_api/controllers/api_v1/cart.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/indoteknik_api/controllers/api_v1/cart.py b/indoteknik_api/controllers/api_v1/cart.py index 0265ec57..d712be4d 100644 --- a/indoteknik_api/controllers/api_v1/cart.py +++ b/indoteknik_api/controllers/api_v1/cart.py @@ -36,14 +36,16 @@ class Cart(controller.Controller): user_id = int(user_id) product_id = int(kw.get('product_id', 0)) qty = int(kw.get('qty', 0)) + source = kw.get('source') is_selected = kw.get('selected', 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 + is_selected = is_selected in ('true', True) + if not user_id or not product_id or not qty: return self.response(code=400, description='user_id, product_id and qty is required') + query = [('user_id', '=', user_id), ('product_id', '=', product_id)] cart = request.env['website.user.cart'].search(query, limit=1) result = {} @@ -52,6 +54,9 @@ class Cart(controller.Controller): 'is_selected': is_selected, 'program_line_id': program_line_id } + if source: + data_to_update['source'] = source + if cart: cart.write(data_to_update) result['id'] = cart.id |
