summaryrefslogtreecommitdiff
path: root/indoteknik_api
diff options
context:
space:
mode:
authorHafidBuroiroh <hafidburoiroh09@gmail.com>2025-10-24 13:49:52 +0700
committerHafidBuroiroh <hafidburoiroh09@gmail.com>2025-10-24 13:49:52 +0700
commit7160ae85c1655c99b2c8f1be77cb3cdb6616043e (patch)
treeec8f4dd1dd695441deb6880aa46da65d457d6225 /indoteknik_api
parentf4a1e2917d550eb205e33b058f07e7edbf8029c8 (diff)
parentf8cb18e7f859792f0862ec8d08a74a67fbba95bc (diff)
merge
Diffstat (limited to 'indoteknik_api')
-rw-r--r--indoteknik_api/controllers/api_v1/sale_order.py13
-rw-r--r--indoteknik_api/controllers/api_v1/stock_picking.py45
2 files changed, 25 insertions, 33 deletions
diff --git a/indoteknik_api/controllers/api_v1/sale_order.py b/indoteknik_api/controllers/api_v1/sale_order.py
index 1a75c830..cff1921d 100644
--- a/indoteknik_api/controllers/api_v1/sale_order.py
+++ b/indoteknik_api/controllers/api_v1/sale_order.py
@@ -728,6 +728,7 @@ class SaleOrder(controller.Controller):
if params['value']['type'] == 'sale_order':
parameters['approval_status'] = 'pengajuan1'
+ # parameters['approval_status'] = False
_logger.info("Setting approval_status to 'pengajuan1'")
sale_order = request.env['sale.order'].with_context(from_website_checkout=True).create([parameters])
@@ -788,7 +789,7 @@ class SaleOrder(controller.Controller):
order_line.product_id_change()
order_line.weight = order_line.product_id.weight
- order_line.onchange_vendor_id()
+ order_line._onchange_vendor_id_custom()
_logger.info(f"After onchanges - Price: {order_line.price_unit}, Disc: {order_line.discount}")
elif cart['cart_type'] == 'promotion':
@@ -808,6 +809,14 @@ class SaleOrder(controller.Controller):
sale_order.apply_promotion_program()
sale_order.add_free_product(promotions)
+ # Pastikan baris hasil promo/bonus ditandai supaya bisa di-skip voucher
+ promo_lines = sale_order.order_line.filtered(
+ lambda l: getattr(l, 'order_promotion_id', False) or (l.price_unit or 0.0) == 0.0
+ )
+ if promo_lines:
+ promo_lines.write({'is_has_disc': True})
+ _logger.info(f"[PROMO_MARK] Marked {len(promo_lines)} promo/free lines as is_has_disc=True")
+
voucher_code = params['value']['voucher']
if voucher_code:
_logger.info(f"Processing voucher: {voucher_code}")
@@ -816,7 +825,7 @@ class SaleOrder(controller.Controller):
voucher_shipping = request.env['voucher'].search(
[('code', '=', voucher_code), ('apply_type', 'in', ['shipping'])], limit=1)
- if voucher and len(promotions) == 0:
+ if voucher:
_logger.info("Applying regular voucher")
sale_order.voucher_id = voucher.id
sale_order.apply_voucher()
diff --git a/indoteknik_api/controllers/api_v1/stock_picking.py b/indoteknik_api/controllers/api_v1/stock_picking.py
index a4a9cf80..fe82e665 100644
--- a/indoteknik_api/controllers/api_v1/stock_picking.py
+++ b/indoteknik_api/controllers/api_v1/stock_picking.py
@@ -1,5 +1,5 @@
from .. import controller
-from odoo import http
+from odoo import http, fields
from odoo.http import request, Response
from pytz import timezone
from datetime import datetime
@@ -8,7 +8,6 @@ import logging
_logger = logging.getLogger(__name__)
-_logger = logging.getLogger(__name__)
class StockPicking(controller.Controller):
prefix = '/api/v1/'
@@ -125,30 +124,10 @@ class StockPicking(controller.Controller):
@http.route(prefix + 'stock-picking/<scanid>/documentation', auth='public', methods=['PUT', 'OPTIONS'], csrf=False)
@controller.Controller.must_authorized()
def write_partner_stock_picking_documentation(self, scanid, **kw):
- sj_document = kw.get('sj_document', False)
- paket_document = kw.get('paket_document', False)
- dispatch_document = kw.get('dispatch_document', False)
-
- # ===== Role by EMAIL =====
- driver_emails = {
- 'driverindoteknik@gmail.com',
- 'sulistianaridwan8@gmail.com',
- }
- dispatch_emails = {
- 'rahmat.afiudin@gmail.com',
- 'it@fixcomart.co.id'
- }
-
- login = (request.env.user.login or '').lower()
- is_dispatch_user = login in dispatch_emails
- is_driver_user = (login in driver_emails) and not is_dispatch_user
-
- # ===== Validasi minimal =====
- if not sj_document or not paket_document:
- return self.response(code=400, description='dispatch_document wajib untuk role dispatch login= %s' % login)
-
- # if is_dispatch_user and not dispatch_document and not is_driver_user:
- # return self.response(code=400, description='dispatch_document wajib untuk role dispatch login= %s' % login)
+ sj_document = kw.get('sj_document') if 'sj_document' in kw else None
+ paket_document = kw.get('paket_document') if 'paket_document' in kw else None
+ dispatch_document = kw.get('dispatch_document') if 'dispatch_document' in kw else None
+ self_pu= kw.get('self_pu') if 'self_pu' in kw else None
# ===== Cari picking by id / picking_code =====
picking_data = False
@@ -161,17 +140,21 @@ class StockPicking(controller.Controller):
if not picking_data:
return self.response(code=403, description='picking not found')
- params = {
- 'sj_documentation': sj_document,
- 'paket_documentation': paket_document,
- 'driver_arrival_date': datetime.utcnow(),
- }
+ params = {}
+ if sj_document:
+ params['sj_documentation'] = sj_document
+ if self_pu:
+ params['driver_arrival_date'] = datetime.utcnow()
+ if paket_document:
+ params['paket_documentation'] = paket_document
+ params['driver_arrival_date'] = datetime.utcnow()
if dispatch_document:
params['dispatch_documentation'] = dispatch_document
picking_data.write(params)
return self.response({'name': picking_data.name})
+
@http.route(prefix + 'webhook/biteship', type='json', auth='public', methods=['POST'], csrf=False)
def update_status_from_biteship(self, **kw):
_logger.info("Biteship Webhook: Request received at controller start (type='json').")