summaryrefslogtreecommitdiff
path: root/indoteknik_api/controllers/api_v1
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2024-11-12 09:49:29 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2024-11-12 09:49:29 +0700
commit9110fb5d93fc7bf9513a0705a22764aca711be26 (patch)
treeaa51b069813001494dbd98bd7c98d444e820bd66 /indoteknik_api/controllers/api_v1
parent200d9ba97ba86f759b3d804c253430230c353fe0 (diff)
parent38c6551a94098370e060e45739dc4c8ae923c48e (diff)
Merge branch 'production' of bitbucket.org:altafixco/indoteknik-addons into production
Diffstat (limited to 'indoteknik_api/controllers/api_v1')
-rw-r--r--indoteknik_api/controllers/api_v1/product.py15
-rw-r--r--indoteknik_api/controllers/api_v1/sale_order.py3
2 files changed, 17 insertions, 1 deletions
diff --git a/indoteknik_api/controllers/api_v1/product.py b/indoteknik_api/controllers/api_v1/product.py
index 9673b3ef..b68eb0f9 100644
--- a/indoteknik_api/controllers/api_v1/product.py
+++ b/indoteknik_api/controllers/api_v1/product.py
@@ -96,6 +96,21 @@ class Product(controller.Controller):
return self.response(data, headers=[('Cache-Control', 'max-age=600, private')])
+ @http.route(prefix + 'product_variant/<id>/qty_available', auth='public', methods=['GET', 'OPTIONS'])
+ @controller.Controller.must_authorized()
+ def get_product_variant_stock_available_by_id(self, **kw):
+ id = int(kw.get('id'))
+ product = request.env['product.product'].search(
+ [('id', '=', id)], limit=1)
+
+ qty_available = product.free_qty
+
+ data = {
+ 'qty': qty_available,
+ }
+
+ return self.response(data, headers=[('Cache-Control', 'max-age=600, private')])
+
@http.route(prefix + 'product/template/price/<id>', auth='public', methods=['GET', 'OPTIONS'])
def get_product_template_price_by_id(self, **kw):
if not self.authenticate():
diff --git a/indoteknik_api/controllers/api_v1/sale_order.py b/indoteknik_api/controllers/api_v1/sale_order.py
index e7664c79..905795b0 100644
--- a/indoteknik_api/controllers/api_v1/sale_order.py
+++ b/indoteknik_api/controllers/api_v1/sale_order.py
@@ -446,7 +446,8 @@ class SaleOrder(controller.Controller):
'company_id': 1,
'order_id': sale_order.id,
'product_id': cart['id'],
- 'product_uom_qty': cart['quantity']
+ 'product_uom_qty': cart['quantity'],
+ 'product_available_quantity': cart['available_quantity']
})
order_line.product_id_change()
order_line.onchange_vendor_id()