diff options
| author | IT Fixcomart <it@fixcomart.co.id> | 2025-07-24 03:57:36 +0000 |
|---|---|---|
| committer | IT Fixcomart <it@fixcomart.co.id> | 2025-07-24 03:57:36 +0000 |
| commit | 170c458eefac4cd331bc7d1d4d8434074c6f829a (patch) | |
| tree | b2f6663762bfb2cbbb656a453d2df79fa206ba0a | |
| parent | a5da6a49dda2d756f907f072a00fb50672893682 (diff) | |
| parent | 365bf9fd1d6cff481c24342db44ef9aeffdd7d80 (diff) | |
Merged in pengajuan_pum (pull request #358)
<hafid> editable field
| -rw-r--r-- | indoteknik_custom/models/refund_sale_order.py | 23 | ||||
| -rw-r--r-- | indoteknik_custom/views/refund_sale_order.xml | 4 |
2 files changed, 16 insertions, 11 deletions
diff --git a/indoteknik_custom/models/refund_sale_order.py b/indoteknik_custom/models/refund_sale_order.py index 559ca07a..e3a0146d 100644 --- a/indoteknik_custom/models/refund_sale_order.py +++ b/indoteknik_custom/models/refund_sale_order.py @@ -17,7 +17,7 @@ class RefundSaleOrder(models.Model): note_refund = fields.Text(string='Note Refund') sale_order_ids = fields.Many2many('sale.order', string='Sales Order Numbers') uang_masuk = fields.Float(string='Uang Masuk', required=True) - total_invoice = fields.Float(string='Total Invoice', compute='_compute_total_invoice', readonly=True) + total_invoice = fields.Float(string='Total Invoice') ongkir = fields.Float(string='Ongkir', required=True, default=0.0) amount_refund = fields.Float(string='Total Refund', required=True) amount_refund_text = fields.Char(string='Total Refund Text', compute='_compute_refund_text') @@ -105,6 +105,10 @@ class RefundSaleOrder(models.Model): ) is_locked = fields.Boolean(string="Locked", compute="_compute_is_locked") + sale_order_names_jasper = fields.Char(string='Sales Order List', compute='_compute_order_invoice_names') + invoice_names_jasper = fields.Char(string='Invoice List', compute='_compute_order_invoice_names') + + @api.depends('refund_type') def _compute_refund_type_display(self): @@ -147,10 +151,10 @@ class RefundSaleOrder(models.Model): invoice_ids_data = vals.get('invoice_ids', []) invoice_ids = invoice_ids_data[0][2] if invoice_ids_data and invoice_ids_data[0][0] == 6 else [] - if invoice_ids and refund_type and refund_type not in ['uang', 'barang_kosong_sebagian', 'retur_half']: + if invoice_ids and refund_type and refund_type not in ['uang', 'barang_kosong_sebagian', 'barang_kosong', 'retur_half']: raise UserError("Refund type Hanya Bisa Lebih Bayar, Barang Kosong Sebagian, atau Retur Sebagian jika ada invoice") - if not invoice_ids and refund_type and refund_type in ['uang', 'barang_kosong_sebagian', 'retur_half']: + if not invoice_ids and refund_type and refund_type in ['uang', 'barang_kosong_sebagian', 'barang_kosong', 'retur_half']: raise UserError("Refund type Lebih Bayar, Barang Kosong Sebagian, atau Retur Sebagian Hanya Bisa dipilih Jika Ada Invoice") @@ -241,10 +245,10 @@ class RefundSaleOrder(models.Model): else: invoice_ids = rec.invoice_ids.ids - if invoice_ids and vals.get('refund_type', rec.refund_type) not in ['uang', 'barang_kosong_sebagian', 'retur_half']: + if invoice_ids and vals.get('refund_type', rec.refund_type) not in ['uang', 'barang_kosong_sebagian', 'barang_kosong', 'retur_half']: raise UserError("Refund type Hanya Bisa Lebih Bayar, Barang Kosong Sebagian, atau Retur Sebagian jika ada invoice") - if not invoice_ids and vals.get('refund_type', rec.refund_type) in ['uang', 'barang_kosong_sebagian', 'retur_half']: + if not invoice_ids and vals.get('refund_type', rec.refund_type) in ['uang', 'barang_kosong_sebagian', 'barang_kosong', 'retur_half']: raise UserError("Refund type Lebih Bayar, Barang Kosong Sebagian, atau Retur Sebagian Hanya Bisa dipilih Jika Ada Invoice") if refund_type in ['retur', 'retur_half'] and so_ids: @@ -279,11 +283,12 @@ class RefundSaleOrder(models.Model): def _compute_is_locked(self): for rec in self: rec.is_locked = rec.status_payment in ['done', 'reject'] - - @api.depends('invoice_ids.amount_total') - def _compute_total_invoice(self): + + @api.depends('sale_order_ids.name', 'invoice_ids.name') + def _compute_order_invoice_names(self): for rec in self: - rec.total_invoice = sum(inv.amount_total for inv in rec.invoice_ids) + rec.sale_order_names_jasper = ', '.join(rec.sale_order_ids.mapped('name')) or '' + rec.invoice_names_jasper = ', '.join(rec.invoice_ids.mapped('name')) or '' @api.depends('sale_order_ids') def _compute_advance_move_names(self): diff --git a/indoteknik_custom/views/refund_sale_order.xml b/indoteknik_custom/views/refund_sale_order.xml index 3b348730..4f791722 100644 --- a/indoteknik_custom/views/refund_sale_order.xml +++ b/indoteknik_custom/views/refund_sale_order.xml @@ -118,9 +118,9 @@ </group> <group> <field name="uang_masuk" attrs="{'readonly': [('is_locked', '=', True)]}"/> - <field name="total_invoice" readonly="1"/> + <field name="total_invoice" attrs="{'readonly': [('is_locked', '=', True)]}"/> <field name="ongkir" attrs="{'readonly': [('is_locked', '=', True)]}"/> - <field name="amount_refund" readonly="1"/> + <field name="amount_refund" attrs="{'readonly': [('is_locked', '=', True)]}"/> <field name="amount_refund_text" readonly="1"/> <field name="uang_masuk_type" required="1" attrs="{'readonly': [('is_locked', '=', True)]}"/> <field name="bukti_uang_masuk_image" widget="image" |
