summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMqdd <ahmadmiqdad27@gmail.com>2026-02-11 09:40:26 +0700
committerMqdd <ahmadmiqdad27@gmail.com>2026-02-11 09:40:26 +0700
commitb2b4be7ed8c92c6ce7b2fbdecd794054eda07437 (patch)
tree89096271119e59a2ff0e188248cd188c9eb6c6be
parent28f98dcaf24923d3f292535bf5f5b1cd1983b809 (diff)
parent0004c43623e74d9b583df1d58fd8219a4bfee366 (diff)
Merge branch 'main' of bitbucket.org:altafixco/fixco-addons
merge
-rw-r--r--fixco_custom/models/account_move_line.py58
1 files changed, 41 insertions, 17 deletions
diff --git a/fixco_custom/models/account_move_line.py b/fixco_custom/models/account_move_line.py
index d192338..1f4ed9d 100644
--- a/fixco_custom/models/account_move_line.py
+++ b/fixco_custom/models/account_move_line.py
@@ -10,38 +10,62 @@ class AccountMoveLine(models.Model):
def action_gl_reconcile(self):
lines = self
- # 1️⃣ Create header bank statement
- account_bank_statement = self.env['account.bank.statement'].create({
- 'journal_id': 25, # pastiin ini journal bank
- 'name': 'REKONSIL KAS IN {}'.format(fields.Datetime.now()),
- 'company_id': 4,
- 'date': fields.Date.today(),
+ journal = self.env['account.journal'].search([
+ ('suspense_account_id', '=', lines[0].account_id.id)
+ ], limit=1)
+
+ if not journal:
+ raise UserError('Journal dengan suspense account ini tidak ditemukan!')
+
+ statement = self.env['account.bank.statement'].create({
+ 'journal_id': journal.id,
+ 'name': f'REKONSIL {journal.name} {lines[0].date.strftime("%d-%m-%Y")}',
+ 'company_id': self.env.company.id,
+ 'date': lines[0].date,
})
- # 2️⃣ Create statement lines dari GL
- statement_lines_vals = []
+ widget_vals = []
+ st_line_ids = []
for line in lines:
- # amount logic:
- # debit = uang masuk
- # credit = uang keluar
amount = line.debit - line.credit
- statement_lines_vals.append({
- 'statement_id': account_bank_statement.id,
+ st_line = self.env['account.bank.statement.line'].create({
+ 'statement_id': statement.id,
'date': line.date or fields.Date.today(),
'payment_ref': line.name,
- 'partner_id': line.partner_id.id if line.partner_id else False,
+ 'partner_id': line.partner_id.id,
'amount': amount,
- 'ref': line.move_id.name,
+ 'ref': line.name,
+ })
+
+ st_line_ids.append(st_line.id)
+
+ widget_vals.append({
+ 'partner_id': st_line.partner_id.id,
+ 'counterpart_aml_dicts': [{
+ 'counterpart_aml_id': line.id,
+ 'debit': abs(amount) if amount < 0 else 0,
+ 'credit': abs(amount) if amount > 0 else 0,
+ 'name': line.name or '/',
+ }],
+ 'payment_aml_ids': [],
+ 'new_aml_dicts': [],
+ 'to_check': False,
})
- self.env['account.bank.statement.line'].create(statement_lines_vals)
+ statement.button_post()
+
+ self.env['account.reconciliation.widget'].process_bank_statement_line(
+ st_line_ids,
+ widget_vals
+ )
+ # statement.button_validate_or_action()
return {
'effect': {
'fadeout': 'slow',
- 'message': 'Statement + lines berhasil dibuat! Tinggal reconcile 😎🔥',
+ 'message': 'Statement + Auto Reconcile sukses besar 😎🔥',
'type': 'rainbow_man',
}
}