From 7fed48782b6790be66cf8134eacc36881eeb29d4 Mon Sep 17 00:00:00 2001 From: HafidBuroiroh Date: Thu, 25 Sep 2025 16:11:07 +0700 Subject: refund --- indoteknik_custom/models/sale_order.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'indoteknik_custom/models/sale_order.py') diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 39830ffc..36dcbb4e 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -3278,10 +3278,17 @@ class SaleOrder(models.Model): ('state', '=', 'posted'), ]) + moves2 = self.env['account.move'].search([ + ('ref', 'ilike', self.name), + ('journal_id', '=', 11), + ('state', '=', 'posted'), + ]) + # Default 0 total_uang_muka = 0.0 has_moves = bool(moves) + has_moves2 = bool(moves2) has_piutangmdr = bool(piutangmdr) has_piutangbca = bool(piutangbca) has_settlement = self.payment_status == 'settlement' @@ -3290,6 +3297,8 @@ class SaleOrder(models.Model): total_uang_muka = sum(moves.mapped('amount_total_signed')) + self.gross_amount elif has_moves: total_uang_muka = sum(moves.mapped('amount_total_signed')) + elif has_moves2: + total_uang_muka = sum(moves2.mapped('amount_total_signed')) elif has_settlement: total_uang_muka = self.gross_amount elif has_piutangbca: @@ -3377,12 +3386,20 @@ class SaleOrder(models.Model): ('state', '=', 'posted'), ]) + moves2 = self.env['account.move'].search([ + ('ref', 'ilike', order.name), + ('journal_id', '=', 11), + ('state', '=', 'posted'), + ]) + total_uang_muka = 0.0 if moves and order.payment_status == 'settlement': total_uang_muka = order.gross_amount + sum(moves.mapped('amount_total_signed')) or 0.0 elif moves: total_uang_muka = sum(moves.mapped('amount_total_signed')) or 0.0 + elif moves2: + total_uang_muka = sum(moves2.mapped('amount_total_signed')) or 0.0 elif order.payment_status == 'settlement': total_uang_muka = order.gross_amount else: -- cgit v1.2.3