diff options
| author | IT Fixcomart <it@fixcomart.co.id> | 2025-09-12 10:14:45 +0000 |
|---|---|---|
| committer | IT Fixcomart <it@fixcomart.co.id> | 2025-09-12 10:14:45 +0000 |
| commit | 7973c3153f852f154c04e1107206ebe90498e771 (patch) | |
| tree | ca6e1f7ba3dcc7816ca41f0797cf1205349351ce | |
| parent | b5c3ba057856d5b0043225b075393842445ba468 (diff) | |
| parent | fb069315f937ea1a8a094d23f22f8314cef412a4 (diff) | |
Merged in refund_system (pull request #411)
Refund system
| -rw-r--r-- | indoteknik_api/controllers/api_v1/user.py | 3 | ||||
| -rw-r--r-- | indoteknik_custom/models/refund_sale_order.py | 28 | ||||
| -rw-r--r-- | indoteknik_custom/models/stock_move.py | 3 | ||||
| -rw-r--r-- | indoteknik_custom/views/account_move.xml | 1 |
4 files changed, 27 insertions, 8 deletions
diff --git a/indoteknik_api/controllers/api_v1/user.py b/indoteknik_api/controllers/api_v1/user.py index c75e4954..3511bc52 100644 --- a/indoteknik_api/controllers/api_v1/user.py +++ b/indoteknik_api/controllers/api_v1/user.py @@ -90,7 +90,8 @@ class User(controller.Controller): 'login': email, 'oauth_provider_id': request.env.ref('auth_oauth.provider_google').id, 'sel_groups_1_9_10': 9, - 'active': True + 'active': True, + } user = request.env['res.users'].create(user_data) diff --git a/indoteknik_custom/models/refund_sale_order.py b/indoteknik_custom/models/refund_sale_order.py index 9ab18f27..f511ed5d 100644 --- a/indoteknik_custom/models/refund_sale_order.py +++ b/indoteknik_custom/models/refund_sale_order.py @@ -463,7 +463,7 @@ class RefundSaleOrder(models.Model): total_invoice = 0.0 so_ids = self.sale_order_ids.ids - + amount_refund_before = 0.0 for so in self.sale_order_ids: self.ongkir += so.delivery_amt or 0.0 valid_invoices = so.invoice_ids.filtered( @@ -471,6 +471,10 @@ class RefundSaleOrder(models.Model): ) all_invoices |= valid_invoices total_invoice += sum(valid_invoices.mapped('amount_total_signed')) + refunds = self.env['refund.sale.order'].search([ + ('sale_order_ids', 'in', so_ids) + ]) + amount_refund_before += sum(refunds.mapped('amount_refund')) if refunds else 0.0 moves = self.env['account.move'].search([ ('sale_id', 'in', so_ids), @@ -479,7 +483,7 @@ class RefundSaleOrder(models.Model): ]) total_uang_muka = sum(moves.mapped('amount_total_signed')) if moves else 0.0 total_midtrans = sum(self.env['sale.order'].browse(so_ids).mapped('gross_amount')) if so_ids else 0.0 - self.uang_masuk = total_uang_muka + total_midtrans + self.uang_masuk = (total_uang_muka + total_midtrans) - amount_refund_before self.invoice_ids = all_invoices @@ -820,15 +824,26 @@ class RefundSaleOrder(models.Model): # Ambil label refund type refund_type_label = dict( self.fields_get(allfields=['refund_type'])['refund_type']['selection'] - ).get(refund.refund_type, '').replace("Refund ", "").upper() - + ).get(refund.refund_type, '') + + # Normalisasi + refund_type_label = refund_type_label.upper() + + if refund.refund_type in ['barang_kosong', 'barang_kosong_sebagian']: + refund_type_label = "REFUND BARANG KOSONG" + elif refund.refund_type in ['retur_half', 'retur']: + refund_type_label = "REFUND RETUR BARANG" + elif refund.refund_type == 'uang': + refund_type_label = "REFUND LEBIH BAYAR" + elif refund.refund_type == 'salah_transfer': + refund_type_label = "REFUND SALAH TRANSFER" if not partner: raise UserError("❌ Partner tidak ditemukan.") # Ref format - ref_text = f"REFUND {refund_type_label} {refund.name or ''} {partner.display_name}".upper() + ref_text = f"{refund_type_label} {refund.name or ''} {partner.display_name}".upper() # Buat Account Move (Journal Entry) account_move = self.env['account.move'].create({ @@ -878,7 +893,8 @@ class RefundSaleOrder(models.Model): def _compute_journal_refund_move_id(self): for rec in self: move = self.env['account.move'].search([ - ('refund_id', '=', rec.id) + ('refund_id', '=', rec.id), + ('state', '!=', 'cancel') ], limit=1) rec.journal_refund_move_id = move diff --git a/indoteknik_custom/models/stock_move.py b/indoteknik_custom/models/stock_move.py index 24d405a6..d6505a86 100644 --- a/indoteknik_custom/models/stock_move.py +++ b/indoteknik_custom/models/stock_move.py @@ -18,7 +18,8 @@ class StockMove(models.Model): barcode = fields.Char(string='Barcode', related='product_id.barcode') vendor_id = fields.Many2one('res.partner' ,string='Vendor') hold_outgoingg = fields.Boolean('Hold Outgoing', default=False) - product_image = fields.Binary(related="product_id.image_128", string="Product Image", readonly = True) + product_image = fields.Binary(related="product_id.image_128", string="Product Image", readonly=True) + # @api.model_create_multi # def create(self, vals_list): # moves = super(StockMove, self).create(vals_list) diff --git a/indoteknik_custom/views/account_move.xml b/indoteknik_custom/views/account_move.xml index 1b477c6d..c88effd5 100644 --- a/indoteknik_custom/views/account_move.xml +++ b/indoteknik_custom/views/account_move.xml @@ -39,6 +39,7 @@ </field> <field name="ref" position="after"> <field name="sale_id" readonly="1" attrs="{'invisible': ['|', ('move_type', '!=', 'entry'), ('has_refund_so', '=', True)]}"/> + <field name="refund_id" readonly="1" attrs="{'invisible': ['|', ('move_type', '!=', 'entry'), ('has_refund_so', '=', False)]}"/> <field name="refund_so_links" readonly="1" widget="html" attrs="{'invisible': ['|', ('move_type', '!=', 'entry'), ('has_refund_so', '=', False)]}"/> <field name="has_refund_so" invisible="1"/> </field> |
