summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/sale_order.py
diff options
context:
space:
mode:
authorIT Fixcomart <it@fixcomart.co.id>2026-01-22 10:47:50 +0000
committerIT Fixcomart <it@fixcomart.co.id>2026-01-22 10:47:50 +0000
commit4ce53750a9732dc2437cbd5cccea9d746b891e6c (patch)
tree77113af0f47a12ffcb71e0c0220d4761d54eb5bf /indoteknik_custom/models/sale_order.py
parent230027f0bfedfedc27e5067d0b25d167f751688b (diff)
parent9e64a74e4576a150d172359999c9eb3cef8505a8 (diff)
Merged in refund_system (pull request #480)
<hafid> cab inv
Diffstat (limited to 'indoteknik_custom/models/sale_order.py')
-rwxr-xr-xindoteknik_custom/models/sale_order.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py
index 9eed236f..469509d4 100755
--- a/indoteknik_custom/models/sale_order.py
+++ b/indoteknik_custom/models/sale_order.py
@@ -3438,7 +3438,7 @@ class SaleOrder(models.Model):
def button_refund(self):
self.ensure_one()
- invoice_ids = self.invoice_ids.filtered(lambda inv: inv.state != 'cancel')
+ invoice_ids = self.invoice_ids.filtered(lambda inv: inv.payment_state == 'paid')
moves = self.env['account.move'].search([
('sale_id', '=', self.id),
@@ -3447,6 +3447,7 @@ class SaleOrder(models.Model):
])
piutangbca = self.env['account.move']
piutangmdr = self.env['account.move']
+ cabinvoice = self.env['account.move']
for inv_name in invoice_ids.mapped('name'):
piutangbca |= self.env['account.move'].search([
@@ -3459,6 +3460,11 @@ class SaleOrder(models.Model):
('journal_id', '=', 7),
('state', '=', 'posted'),
])
+ cabinvoice |= self.env['account.move'].search([
+ ('ref', 'ilike', inv_name),
+ ('journal_id', '=', 11),
+ ('state', '=', 'posted'),
+ ])
moves2 = self.env['account.move'].search([
('ref', 'ilike', self.name),
@@ -3473,6 +3479,7 @@ class SaleOrder(models.Model):
has_moves2 = bool(moves2)
has_piutangmdr = bool(piutangmdr)
has_piutangbca = bool(piutangbca)
+ has_cabinvoice = bool(cabinvoice)
has_settlement = self.payment_status == 'settlement'
if has_moves and has_settlement:
@@ -3483,6 +3490,8 @@ class SaleOrder(models.Model):
total_uang_muka = sum(moves2.mapped('amount_total_signed'))
elif has_settlement:
total_uang_muka = self.gross_amount
+ elif has_cabinvoice:
+ total_uang_muka = sum(cabinvoice.mapped('amount_total_signed'))
elif has_piutangbca:
total_uang_muka = sum(piutangbca.mapped('amount_total_signed'))
elif has_piutangmdr: