diff options
| author | Mqdd <ahmadmiqdad27@gmail.com> | 2026-01-05 08:56:00 +0700 |
|---|---|---|
| committer | Mqdd <ahmadmiqdad27@gmail.com> | 2026-01-05 08:56:00 +0700 |
| commit | 8bb3696e35dc122ea153566834a48ec0659e0101 (patch) | |
| tree | a87d73ab5be013d70287b5c9d735344edd53a8eb | |
| parent | 9039bb8de5ea157692120b8b2dd24338a13a0071 (diff) | |
| parent | 449e19edc55b2b64b218e56b8216ba56a04c5d3f (diff) | |
Merge branch 'odoo-backup' of https://bitbucket.org/altafixco/indoteknik-addons into cr_renca_find
| -rw-r--r-- | indoteknik_custom/models/refund_sale_order.py | 81 |
1 files changed, 80 insertions, 1 deletions
diff --git a/indoteknik_custom/models/refund_sale_order.py b/indoteknik_custom/models/refund_sale_order.py index 0ff0a2f0..c22e84ab 100644 --- a/indoteknik_custom/models/refund_sale_order.py +++ b/indoteknik_custom/models/refund_sale_order.py @@ -348,12 +348,38 @@ class RefundSaleOrder(models.Model): domain.append(('ref', 'ilike', n)) moves3 = self.env['account.move'].search(domain) + moves_ongkir = self.env['account.move'] + if so_ids: + so_records = self.env['sale.order'].browse(so_ids) + so_names = so_records.mapped('name') + + domain = [ + ('journal_id', '=', 11), + ('state', '=', 'posted'), + ('sale_id', '=', False), + '|', + ('ref', 'ilike', 'pendapatan ongkos kirim'), + ('ref', 'ilike', 'ongkir'), + '|', + ('line_ids.account_id', '=', 450), + ('line_ids.account_id', '=', 668), + ] + + if so_names: + domain += ['|'] * (len(so_names) - 1) + for name in so_names: + domain.append(('ref', 'ilike', name)) + + moves_ongkir = self.env['account.move'].search(domain) + + has_moves = bool(moves) has_moves2 = bool(moves2) has_moves3 = bool(moves3) has_piutangmdr = bool(piutangmdr) has_piutangbca = bool(piutangbca) has_misc = bool(misc) + has_ongkir = bool(moves_ongkir) ssos = self.env['sale.order'].browse(so_ids) has_settlement = any(so.payment_status == 'settlement' for so in ssos) @@ -363,6 +389,8 @@ class RefundSaleOrder(models.Model): if has_moves: sisa_uang_masuk += sum(moves.mapped('amount_total_signed')) + if has_ongkir: + sisa_uang_masuk += sum(moves_ongkir.mapped('amount_total_signed')) if has_moves2: sisa_uang_masuk += sum(moves2.mapped('amount_total_signed')) if has_moves3: @@ -615,7 +643,31 @@ class RefundSaleOrder(models.Model): ('state', '=', 'posted'), ]) - all_moves = moves | piutangbca | piutangmdr | misc | moves2 + moves_ongkir = self.env['account.move'] + if rec.sale_order_ids: + so_records = rec.sale_order_ids + so_names = so_records.mapped('name') + + domain = [ + ('journal_id', '=', 11), + ('state', '=', 'posted'), + ('sale_id', '=', False), + '|', + ('ref', 'ilike', 'pendapatan ongkos kirim'), + ('ref', 'ilike', 'ongkir'), + '|', + ('line_ids.account_id', '=', 450), + ('line_ids.account_id', '=', 668), + ] + + if so_names: + domain += ['|'] * (len(so_names) - 1) + for name in so_names: + domain.append(('ref', 'ilike', name)) + + moves_ongkir = self.env['account.move'].search(domain) + + all_moves = moves | piutangbca | piutangmdr | misc | moves2 | moves_ongkir for move in all_moves: url = f"/web#id={move.id}&model=account.move&view_type=form" @@ -683,6 +735,30 @@ class RefundSaleOrder(models.Model): ('state', '=', 'posted'), ]) + moves_ongkir = self.env['account.move'] + if so_ids: + so_records = self.env['sale.order'].browse(so_ids) + so_names = so_records.mapped('name') + + domain = [ + ('journal_id', '=', 11), + ('state', '=', 'posted'), + ('sale_id', '=', False), + '|', + ('ref', 'ilike', 'pendapatan ongkos kirim'), + ('ref', 'ilike', 'ongkir'), + '|', + ('line_ids.account_id', '=', 450), + ('line_ids.account_id', '=', 668), + ] + + if so_names: + domain += ['|'] * (len(so_names) - 1) + for name in so_names: + domain.append(('ref', 'ilike', name)) + + moves_ongkir = self.env['account.move'].search(domain) + moves2 = self.env['account.move'] if so_ids: so_records = self.env['sale.order'].browse(so_ids) @@ -724,6 +800,7 @@ class RefundSaleOrder(models.Model): has_piutangmdr = bool(piutangmdr) has_piutangbca = bool(piutangbca) has_misc = bool(misc) + has_ongkir = bool(moves_ongkir) ssos = self.env['sale.order'].browse(so_ids) has_settlement = any(so.payment_status == 'settlement' for so in ssos) @@ -743,6 +820,8 @@ class RefundSaleOrder(models.Model): sisa_uang_masuk += sum(piutangmdr.mapped('amount_total_signed')) if has_misc: sisa_uang_masuk += sum(misc.mapped('amount_total_signed')) + if has_ongkir: + sisa_uang_masuk += sum(moves_ongkir.mapped('amount_total_signed')) if has_settlement and not has_journal: sisa_uang_masuk += sum(ssos.mapped('gross_amount')) |
