diff options
| author | FIN-IT_AndriFP <andrifebriyadiputra@gmail.com> | 2026-01-23 09:40:58 +0700 |
|---|---|---|
| committer | FIN-IT_AndriFP <andrifebriyadiputra@gmail.com> | 2026-01-23 09:40:58 +0700 |
| commit | 4f3d357070649a8f524eec481ec6ff474e7422a5 (patch) | |
| tree | 0ca16e911f342b1cfdaebec146c911cc39d8d431 | |
| parent | 9496bae642b86438f0dcef1595255e2f01384040 (diff) | |
| parent | 4ce53750a9732dc2437cbd5cccea9d746b891e6c (diff) | |
Merge branch 'odoo-backup' of https://bitbucket.org/altafixco/indoteknik-addons into odoo-backup
| -rw-r--r-- | indoteknik_custom/models/refund_sale_order.py | 38 | ||||
| -rwxr-xr-x | indoteknik_custom/models/sale_order.py | 11 | ||||
| -rwxr-xr-x | indoteknik_custom/models/x_manufactures.py | 1 | ||||
| -rwxr-xr-x | indoteknik_custom/views/x_manufactures.xml | 1 |
4 files changed, 42 insertions, 9 deletions
diff --git a/indoteknik_custom/models/refund_sale_order.py b/indoteknik_custom/models/refund_sale_order.py index 722a125e..1c482619 100644 --- a/indoteknik_custom/models/refund_sale_order.py +++ b/indoteknik_custom/models/refund_sale_order.py @@ -242,7 +242,7 @@ class RefundSaleOrder(models.Model): ) invoices = sale_orders.mapped('invoice_ids').filtered( - lambda inv: inv.move_type in ['out_invoice', 'out_refund'] and inv.state != 'cancel' + lambda inv: inv.move_type in ['out_invoice', 'out_refund'] and inv.payment_state == 'paid' ) if invoices: vals['invoice_ids'] = [(6, 0, invoices.ids)] @@ -296,6 +296,7 @@ class RefundSaleOrder(models.Model): ]) piutangbca = self.env['account.move'] piutangmdr = self.env['account.move'] + cabinvoice = self.env['account.move'] for inv_name in invoices.mapped('name'): piutangbca |= self.env['account.move'].search([ @@ -308,6 +309,11 @@ class RefundSaleOrder(models.Model): ('journal_id', '=', 7), ('state', '=', 'posted'), ]) + cabinvoice |= self.env['account.move'].search([ + ('ref', 'ilike', inv_name), + ('journal_id', '=', 11), + ('state', '=', 'posted'), + ]) misc = self.env['account.move'] if invoices: @@ -378,6 +384,7 @@ class RefundSaleOrder(models.Model): has_moves3 = bool(moves3) has_piutangmdr = bool(piutangmdr) has_piutangbca = bool(piutangbca) + has_cabinvoice = bool(cabinvoice) has_misc = bool(misc) has_ongkir = bool(moves_ongkir) ssos = self.env['sale.order'].browse(so_ids) @@ -385,7 +392,7 @@ class RefundSaleOrder(models.Model): sisa_uang_masuk = 0.0 - has_journal = has_moves or has_moves2 or has_moves3 or has_piutangbca or has_piutangmdr or has_misc + has_journal = has_moves or has_moves2 or has_moves3 or has_piutangbca or has_piutangmdr or has_misc or has_cabinvoice if has_moves: sisa_uang_masuk += sum(moves.mapped('amount_total_signed')) @@ -397,6 +404,8 @@ class RefundSaleOrder(models.Model): sisa_uang_masuk += sum(moves3.mapped('amount_total_signed')) if has_piutangbca: sisa_uang_masuk += sum(piutangbca.mapped('amount_total_signed')) + if has_cabinvoice: + sisa_uang_masuk += sum(cabinvoice.mapped('amount_total_signed')) if has_piutangmdr: sisa_uang_masuk += sum(piutangmdr.mapped('amount_total_signed')) if has_misc: @@ -483,7 +492,7 @@ class RefundSaleOrder(models.Model): valid_invoices = sale_orders.mapped('invoice_ids').filtered( - lambda inv: inv.move_type in ['out_invoice', 'out_refund'] and inv.state != 'cancel' + lambda inv: inv.move_type in ['out_invoice', 'out_refund'] and inv.payment_state == 'paid' ) vals['invoice_ids'] = [(6, 0, valid_invoices.ids)] vals['ongkir'] = sum(so.delivery_amt or 0.0 for so in sale_orders) @@ -592,9 +601,7 @@ class RefundSaleOrder(models.Model): for rec in self: move_links = [] - invoice_ids = rec.sale_order_ids.mapped('invoice_ids').filtered( - lambda inv: inv.state == 'posted' - ) + invoice_ids = rec.sale_order_ids.mapped('invoice_ids') moves = self.env['account.move'].search([ ('sale_id', 'in', rec.sale_order_ids.ids), @@ -604,6 +611,7 @@ class RefundSaleOrder(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([ @@ -616,6 +624,11 @@ class RefundSaleOrder(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'] if rec.sale_order_ids: @@ -669,7 +682,7 @@ class RefundSaleOrder(models.Model): moves_ongkir = self.env['account.move'].search(domain) - all_moves = moves | piutangbca | piutangmdr | misc | moves2 | moves_ongkir + all_moves = moves | piutangbca | piutangmdr | misc | moves2 | moves_ongkir | cabinvoice for move in all_moves: url = f"/web#id={move.id}&model=account.move&view_type=form" @@ -697,7 +710,7 @@ class RefundSaleOrder(models.Model): for so in self.sale_order_ids: self.ongkir += so.delivery_amt or 0.0 valid_invoices = so.invoice_ids.filtered( - lambda inv: inv.move_type in ['out_invoice', 'out_refund'] and inv.state != 'cancel' + lambda inv: inv.move_type in ['out_invoice', 'out_refund'] and inv.payment_state == 'paid' ) all_invoices |= valid_invoices total_invoice += sum(valid_invoices.mapped('amount_total_signed')) @@ -715,6 +728,7 @@ class RefundSaleOrder(models.Model): piutangbca = self.env['account.move'] piutangmdr = self.env['account.move'] + cabinvoice = self.env['account.move'] for inv_name in all_invoices.mapped('name'): piutangbca |= self.env['account.move'].search([ @@ -727,6 +741,11 @@ class RefundSaleOrder(models.Model): ('journal_id', '=', 7), ('state', '=', 'posted'), ]) + cabinvoice |= self.env['account.move'].search([ + ('ref', 'ilike', inv_name), + ('journal_id', '=', 11), + ('state', '=', 'posted'), + ]) misc = self.env['account.move'] if all_invoices: @@ -801,6 +820,7 @@ class RefundSaleOrder(models.Model): has_moves3 = bool(moves3) has_piutangmdr = bool(piutangmdr) has_piutangbca = bool(piutangbca) + has_cabinvoice = bool(cabinvoice) has_misc = bool(misc) has_ongkir = bool(moves_ongkir) ssos = self.env['sale.order'].browse(so_ids) @@ -814,6 +834,8 @@ class RefundSaleOrder(models.Model): sisa_uang_masuk += sum(moves.mapped('amount_total_signed')) if has_moves2: sisa_uang_masuk += sum(moves2.mapped('amount_total_signed')) + if has_cabinvoice: + sisa_uang_masuk += sum(cabinvoice.mapped('amount_total_signed')) if has_moves3: sisa_uang_masuk += sum(moves3.mapped('amount_total_signed')) if has_piutangbca: 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: diff --git a/indoteknik_custom/models/x_manufactures.py b/indoteknik_custom/models/x_manufactures.py index b4b61296..9e214d92 100755 --- a/indoteknik_custom/models/x_manufactures.py +++ b/indoteknik_custom/models/x_manufactures.py @@ -50,6 +50,7 @@ class XManufactures(models.Model): # user_id = fields.Many2one('res.users', string='Responsible', domain="['|'('id', '=', 19), ('id', '=', 6)]", help="Siapa yang bertanggung jawab") user_id = fields.Many2one('res.users', string='Responsible', help="Siapa yang bertanggung jawab") override_vendor_id = fields.Many2one('res.partner', string='Override Vendor') + # cashback_percent = fields.Float(string='Cashback Percent') def _compute_vendor_ids(self): for manufacture in self: diff --git a/indoteknik_custom/views/x_manufactures.xml b/indoteknik_custom/views/x_manufactures.xml index 02061251..d5cec350 100755 --- a/indoteknik_custom/views/x_manufactures.xml +++ b/indoteknik_custom/views/x_manufactures.xml @@ -82,6 +82,7 @@ <field name="x_negara_asal"/> <field name="x_short_desc"/> <field name="x_manufacture_level"/> + <!-- <field name="cashback_percent" widget="percentage"/> --> <field name="x_produk_aksesoris_sparepart"/> <field name="cache_reset_status"/> <field name="parent_id"/> |
