diff options
Diffstat (limited to 'indoteknik_api/controllers/api_v1')
| -rw-r--r-- | indoteknik_api/controllers/api_v1/product.py | 59 |
1 files changed, 24 insertions, 35 deletions
diff --git a/indoteknik_api/controllers/api_v1/product.py b/indoteknik_api/controllers/api_v1/product.py index 74dadb01..9b7b5a9d 100644 --- a/indoteknik_api/controllers/api_v1/product.py +++ b/indoteknik_api/controllers/api_v1/product.py @@ -15,46 +15,35 @@ class Product(controller.Controller): @http.route(prefix + 'product/template/stock/<id>', auth='public', methods=['GET', 'OPTIONS']) def get_product_template_stock_by_id(self, **kw): id = kw.get('id') - stock_location_id = 57 # Ubah dengan location_id yang diinginkan product = request.env['product.product'].search([('id', '=', id)], limit=1) - # stock = product.qty_available - 10 - item_code = product.default_code - qty_altama = request.env['product.template'].get_stock_altama(item_code) - qty_altama -= int(qty_altama * 0.1) - rounded_qty_altama = math.ceil(float(qty_altama)) - qty_b2b_altama = rounded_qty_altama - + product_sla = request.env['product.sla'].search([('product_variant_id', '=', id)], limit=1) + + qty_available = product.qty_onhand_bandengan + qty_available -= 10 + if qty_available < 10: + qty_available = 0 + qty = 0 sla_date = '-' - qty_available = 0 - product_altama = product.x_manufacture.id == 10 or product.x_manufacture.id == 122 or product.x_manufacture.id == 89 - - for stock in product.stock_quant_ids: - if stock.location_id.id == stock_location_id: - qty_available += stock.quantity - - qty_available -= 10 - if qty_available == 0: - if qty_b2b_altama > 0: - qty = qty_b2b_altama - sla_date = '2-4 Hari' - else: - qty = 0 - sla_date = 'Indent' - elif qty_available > 10: - if product_altama: - qty = qty_available + qty_b2b_altama - sla_date = '2-4 Hari' - else: - qty = qty_available + + is_altama_product = product.x_manufacture.id in [10,122,89] + qty_altama = request.env['product.template'].get_stock_altama(product.default_code) + qty_altama -= int(qty_altama * 0.1) + qty_altama = math.ceil(float(qty_altama)) + if is_altama_product: + if qty_available > 10: + qty = qty_altama + qty_available sla_date = '1 Hari' - elif qty_available < 10: - if qty_b2b_altama > 0 and qty_available > 0 and product_altama: - qty = qty_b2b_altama + qty_available - sla_date = '2-4 Hari' else: - qty = 0 - sla_date = '-' + if qty_altama > 0: + qty = qty_altama + sla_date = '2-4 Hari' + else: + sla_date = 'Indent' + else: + if qty_available > 0: + qty = qty_available + sla_date = product_sla.sla or '-' data = { 'qty': qty, |
