summaryrefslogtreecommitdiff
path: root/indoteknik_api/controllers/api_v1/sale_order.py
diff options
context:
space:
mode:
authorFIN-IT_AndriFP <it@fixcomart.co.id>2025-10-15 15:13:19 +0700
committerFIN-IT_AndriFP <it@fixcomart.co.id>2025-10-15 15:13:19 +0700
commit787ce986cc652bd92d0e477c11853eaef871b4e5 (patch)
tree5b9df5e357e301d84554618e3592bdfd389c8178 /indoteknik_api/controllers/api_v1/sale_order.py
parentc04dd5a6a38ba35b30a39ed6596514679067e541 (diff)
parentee6d5d4433a397ca5cdf3474f29bcbd0b2553736 (diff)
Merge branch 'odoo-backup' of https://bitbucket.org/altafixco/indoteknik-addons into matches-so-v2
Diffstat (limited to 'indoteknik_api/controllers/api_v1/sale_order.py')
-rw-r--r--indoteknik_api/controllers/api_v1/sale_order.py11
1 files changed, 10 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..741dc0b1 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])
@@ -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()