diff options
| author | trisusilo48 <tri.susilo@altama.co.id> | 2025-04-16 14:33:31 +0700 |
|---|---|---|
| committer | trisusilo48 <tri.susilo@altama.co.id> | 2025-04-16 14:33:31 +0700 |
| commit | fb50d10576f2e5d16faba612dfd1565f7168f655 (patch) | |
| tree | 4732e28fe569e6adbdf621f5f54b9b80d4a0ccb1 /indoteknik_api/controllers/api_v1 | |
| parent | b3e915fa8d2f280d76ca1afb19e729804aeed6e6 (diff) | |
FEEDBACK
Diffstat (limited to 'indoteknik_api/controllers/api_v1')
| -rw-r--r-- | indoteknik_api/controllers/api_v1/product.py | 74 | ||||
| -rw-r--r-- | indoteknik_api/controllers/api_v1/stock_picking.py | 16 |
2 files changed, 78 insertions, 12 deletions
diff --git a/indoteknik_api/controllers/api_v1/product.py b/indoteknik_api/controllers/api_v1/product.py index a88c3368..260dd462 100644 --- a/indoteknik_api/controllers/api_v1/product.py +++ b/indoteknik_api/controllers/api_v1/product.py @@ -96,22 +96,25 @@ class Product(controller.Controller): }) @http.route(prefix + 'product_variant/<id>/stock', auth='public', methods=['GET', 'OPTIONS']) - @controller.Controller.must_authorized() + @controller.Controller.must_authorized() def get_product_template_stock_by_id(self, **kw): id = int(kw.get('id')) date_7_days_ago = datetime.now() - timedelta(days=7) - product = request.env['product.product'].search( - [('id', '=', id)], limit=1) + product_pruchase = request.env['purchase.pricelist'].search([ + ('product_id', '=', id), + ('is_winner', '=', True) + ]) product_sla = request.env['product.sla'].search( [('product_variant_id', '=', id)], limit=1) stock_vendor = request.env['stock.vendor'].search([ ('product_variant_id', '=', id), ('write_date', '>=', date_7_days_ago.strftime("%Y-%m-%d %H:%M:%S")) ], limit=1) + + product = product_pruchase.product_id qty_available = product.qty_free_bandengan - if qty_available < 1 : qty_available = 0 @@ -157,7 +160,68 @@ class Product(controller.Controller): 'sla_date': sla_date } - return self.response(data, headers=[('Cache-Control', 'max-age=600, private')]) + return self.response(data, headers=[('Cache-Control', 'max-age=600, private')]) + # def get_product_template_stock_by_id(self, **kw): + # id = int(kw.get('id')) + # date_7_days_ago = datetime.now() - timedelta(days=7) + # product = request.env['product.product'].search( + # [('id', '=', id)], limit=1) + # product_sla = request.env['product.sla'].search( + # [('product_variant_id', '=', id)], limit=1) + # stock_vendor = request.env['stock.vendor'].search([ + # ('product_variant_id', '=', id), + # ('write_date', '>=', date_7_days_ago.strftime("%Y-%m-%d %H:%M:%S")) + # ], limit=1) + + # qty_available = product.qty_free_bandengan + + + # if qty_available < 1 : + # qty_available = 0 + + # qty = 0 + # sla_date = '-' + + # # Qty Stock Vendor + # qty_vendor = stock_vendor.quantity + # qty_vendor -= int(qty_vendor * 0.1) + # qty_vendor = math.ceil(float(qty_vendor)) + # total_excell = qty_vendor + + # is_altama_product = product.x_manufacture.id in [10, 122, 89] + # if is_altama_product: + # try: + # # Qty Altama + # 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)) + # total_adem = qty_altama + + # if qty_available > 0: + # qty = qty_available + total_adem + total_excell + # sla_date = product_sla.sla or 1 + # elif qty_altama > 0 or qty_vendor > 0: + # qty = total_adem if qty_altama > 0 else total_excell + # sla_date = product_sla.sla + # else: + # sla_date = product_sla.sla + # except: + # print('error') + # else: + # if qty_available > 0: + # qty = qty_available + # sla_date = product_sla.sla or 'Indent' + # elif qty_vendor > 0: + # qty = total_excell + # sla_date = '2-4 Hari' + + # data = { + # 'qty': qty, + # 'sla_date': sla_date + # } + + # 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() diff --git a/indoteknik_api/controllers/api_v1/stock_picking.py b/indoteknik_api/controllers/api_v1/stock_picking.py index 0a15d969..abd78f0e 100644 --- a/indoteknik_api/controllers/api_v1/stock_picking.py +++ b/indoteknik_api/controllers/api_v1/stock_picking.py @@ -160,21 +160,23 @@ class StockPicking(controller.Controller): def process_order_status(self, data): picking_model = request.env['stock.picking'].sudo().search([('biteship_id', '=', data.get('order_id'))], limit=1) - if data.get('status') == 'picked': - picking_model.write({'driver_departure_date': datetime.utcnow()}) - elif data.get('status') == 'delivered': - picking_model.write({'driver_arrival_date': datetime.utcnow()}) + if picking_model : + if data.get('status') == 'picked': + result = picking_model.write({'driver_departure_date': datetime.utcnow()}) + print(result) + elif data.get('status') == 'delivered': + picking_model.write({'driver_arrival_date': datetime.utcnow()}) def process_order_price(self, data): - picking_model = request.env['stock.picking'].sudo().search([('biteship_id', '=', data.get('order_id'))], limit=1) - order = request.env['sale.order'].sudo().search([('name', '=', picking_model.sale_id.name)], limit=1) + picking_model = request.env['stock.picking'].search([('biteship_id', '=', data.get('order_id'))], limit=1) + order = request.env['sale.order'].search([('name', '=', picking_model.sale_id.name)], limit=1) if order: order.write({ 'delivery_amt': data.get('price') }) def process_order_waybill(self, data): - picking_model = request.env['stock.picking'].sudo().search([('biteship_id', '=', data.get('order_id'))], limit=1) + picking_model = request.env['stock.picking'].search([('biteship_id', '=', data.get('order_id'))], limit=1) if picking_model: picking_model.write({ 'biteship_waybill_id': data.get('courier_waybill_id'), |
