summaryrefslogtreecommitdiff
path: root/indoteknik_api
diff options
context:
space:
mode:
Diffstat (limited to 'indoteknik_api')
-rw-r--r--indoteknik_api/controllers/api_v1/sale_order.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/indoteknik_api/controllers/api_v1/sale_order.py b/indoteknik_api/controllers/api_v1/sale_order.py
index 1a75c830..25268856 100644
--- a/indoteknik_api/controllers/api_v1/sale_order.py
+++ b/indoteknik_api/controllers/api_v1/sale_order.py
@@ -808,6 +808,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 +824,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()