summaryrefslogtreecommitdiff
path: root/indoteknik_api/controllers/api_v1
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2024-08-29 13:09:54 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2024-08-29 13:09:54 +0700
commit0e9e58da406e62a72ce2ba18c6317e3de57963a1 (patch)
treee71748bf819c9760400183029aaede2a00772a3a /indoteknik_api/controllers/api_v1
parentf4c67f4f8ef9ffc9da3e0406cb08fffb6ba44fd4 (diff)
cr api voucher
Diffstat (limited to 'indoteknik_api/controllers/api_v1')
-rw-r--r--indoteknik_api/controllers/api_v1/sale_order.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/indoteknik_api/controllers/api_v1/sale_order.py b/indoteknik_api/controllers/api_v1/sale_order.py
index b351bacc..f6417bf9 100644
--- a/indoteknik_api/controllers/api_v1/sale_order.py
+++ b/indoteknik_api/controllers/api_v1/sale_order.py
@@ -342,11 +342,21 @@ class SaleOrder(controller.Controller):
@http.route(prefix + 'user/<user_id>/sale_order/checkout', auth='public', method=['GET', 'OPTIONS'], csrf=False)
@controller.Controller.must_authorized(private=True, private_key='user_id')
def get_user_checkout_so(self, user_id, **kw):
- cart = request.env['website.user.cart']
+ m_voucher = request.env['voucher']
+ m_cart = request.env['website.user.cart']
+
voucher_code = kw.get('voucher')
+ voucher_shipping_code = kw.get('voucher_shipping')
source = kw.get('source')
- voucher = request.env['voucher'].search([('code', '=', voucher_code)], limit=1)
- result = cart.with_context(price_for="web").get_user_checkout(user_id, voucher, source)
+
+ voucher = m_voucher.search([('code', '=', voucher_code)], limit=1)
+ voucher_shipping = m_voucher.search([('code', '=', voucher_shipping_code)], limit=1)
+ result = m_cart.with_context(price_for="web").get_user_checkout(
+ user_id,
+ voucher=voucher,
+ voucher_shipping=voucher_shipping,
+ source=source
+ )
return self.response(result)
@http.route(PREFIX_PARTNER + 'sale_order/checkout', auth='public', method=['POST', 'OPTIONS'], csrf=False)