From 4c2325d4a983ced3a25a9d53d7613a9186360b17 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Wed, 16 Oct 2024 13:15:11 +0700 Subject: update ready stock picup quantity --- indoteknik_api/controllers/api_v1/product.py | 15 +++++++++++++++ indoteknik_api/controllers/api_v1/sale_order.py | 3 ++- indoteknik_api/models/sale_order.py | 1 + 3 files changed, 18 insertions(+), 1 deletion(-) (limited to 'indoteknik_api') 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//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/', 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() diff --git a/indoteknik_api/models/sale_order.py b/indoteknik_api/models/sale_order.py index 725dbb4b..8e0371a3 100644 --- a/indoteknik_api/models/sale_order.py +++ b/indoteknik_api/models/sale_order.py @@ -84,6 +84,7 @@ class SaleOrder(models.Model): 'subtotal': line.price_subtotal } product['quantity'] = line.product_uom_qty + product['available_quantity'] = line.product_available_quantity data_with_detail['products'].append(product) for invoice in sale_order.invoice_ids: if invoice.state == 'posted': -- cgit v1.2.3