diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2026-01-14 17:04:53 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2026-01-14 17:04:53 +0700 |
| commit | cc31429011b566c64792898b63d1e62d723ab127 (patch) | |
| tree | 434f82538291f5dab6e6cf55f8fcc8221ae8b952 | |
| parent | 467d67725055822e048e2e0a689a8cc3ffe4a271 (diff) | |
push req iqmal
| -rw-r--r-- | fixco_custom/models/account_move_reversal.py | 5 | ||||
| -rw-r--r-- | fixco_custom/models/purchase_order.py | 1 | ||||
| -rwxr-xr-x | fixco_custom/models/stock_picking.py | 38 | ||||
| -rw-r--r-- | fixco_custom/models/uangmuka_pembelian.py | 2 | ||||
| -rw-r--r-- | fixco_custom/views/purchase_order.xml | 1 |
5 files changed, 45 insertions, 2 deletions
diff --git a/fixco_custom/models/account_move_reversal.py b/fixco_custom/models/account_move_reversal.py index 2645645..745346a 100644 --- a/fixco_custom/models/account_move_reversal.py +++ b/fixco_custom/models/account_move_reversal.py @@ -45,8 +45,13 @@ class AccountMoveReversal(models.TransientModel): for move in moves.with_context(include_business_fields=True): moves_vals_list.append(move.copy_data({'date': self.date if self.date_mode == 'custom' else move.date})[0]) new_moves = self.env['account.move'].create(moves_vals_list) + + new_moves.action_post() moves_to_redirect |= new_moves + move_line = self.env['account.move.line'].search([('move_id', '=', new_moves.id), ('account_id', '=', 347), ('journal_id', '=', 17)], limit=1) + if move_line and move_line.move_id.reversed_entry_id: + moves.js_assign_outstanding_line(move_line.id) self.new_move_ids = moves_to_redirect diff --git a/fixco_custom/models/purchase_order.py b/fixco_custom/models/purchase_order.py index 3db2d04..07ac1d9 100644 --- a/fixco_custom/models/purchase_order.py +++ b/fixco_custom/models/purchase_order.py @@ -58,6 +58,7 @@ class PurchaseOrder(models.Model): soo_tax = fields.Float('SOO Tax', copy=False) discount_total = fields.Float('Discount Total', help = 'Total Discount for Each Product', copy=False, default=0.0) bill_date = fields.Date('Bill Date', copy=False) + uangmuka_exist = fields.Boolean('Uang Muka Exist', copy=False) def _prepare_invoice(self): """Prepare the dict of values to create the new invoice for a purchase order. diff --git a/fixco_custom/models/stock_picking.py b/fixco_custom/models/stock_picking.py index a3101d3..526a0eb 100755 --- a/fixco_custom/models/stock_picking.py +++ b/fixco_custom/models/stock_picking.py @@ -160,13 +160,49 @@ class StockPicking(models.Model): if self.name.startswith('BU/INT') and self.picking_type_code == 'internal' and self.env.user.id not in [10,15,2] and self.location_dest_id.id == 86: raise UserError(_("Hanya bang rafly hanggara yang bisa validate")) - + res = super(StockPicking, self).button_validate() + if self.name.startswith('BU/IN') and self.origin.startswith('Return of BU/OUT') and self.state == 'done': + self.automatic_reversed_invoice() # if self.name.startswith('BU/OUT') and self.origin.startswith('SO/'): # self.create_invoices() return res + + def automatic_reversed_invoice(self): + origin = self.origin or '' + clean_origin = origin.replace('Return of ', '') + + return_picking = self.env['stock.picking'].search([ + ('name', '=', clean_origin), + ('state', '=', 'done') + ], limit=1) + + if not return_picking: + return False + + account_move = self.env['account.move'].search([ + ('picking_id', '=', return_picking.id), + ('state', '=', 'posted') + ], limit=1) + + if not account_move: + return False + + reversal = self.env['account.move.reversal'].create({ + 'move_ids': [(6, 0, account_move.ids)], + 'date_mode': 'custom', + 'date': fields.Date.context_today(self), + 'refund_method': 'refund', + 'reason': _('Auto reverse from return picking %s') % self.name, + 'company_id': account_move.company_id.id, + }) + + action = reversal.reverse_moves() + + return action + @api.depends('move_lines.origin_returned_move_id') diff --git a/fixco_custom/models/uangmuka_pembelian.py b/fixco_custom/models/uangmuka_pembelian.py index 6820c0d..ef2767c 100644 --- a/fixco_custom/models/uangmuka_pembelian.py +++ b/fixco_custom/models/uangmuka_pembelian.py @@ -109,7 +109,7 @@ class UangmukaPembelian(models.TransientModel): request.env['account.move.line'].create([param_debit, param_debit_selisih, param_credit]) else: request.env['account.move.line'].create([param_debit, param_credit]) - # order.is_create_uangmuka = True + order.uangmuka_exist = True order.move_entry_id = account_move.id return { 'name': _('Journal Entries'), diff --git a/fixco_custom/views/purchase_order.xml b/fixco_custom/views/purchase_order.xml index d254c92..12b7c4b 100644 --- a/fixco_custom/views/purchase_order.xml +++ b/fixco_custom/views/purchase_order.xml @@ -45,6 +45,7 @@ <field name="source" readonly="1"/> <field name="move_entry_id" readonly="1"/> <field name="bill_date" readonly="1"/> + <field name="uangmuka_exist" readonly="1"/> </field> <field name="amount_untaxed" position="after"> <field name="amount_discount" class="oe_currency_line"/> |
