fix journal movement

This commit is contained in:
admin.suherdy 2025-12-05 19:40:28 +07:00
parent 3c9a910d8f
commit 822ed95c53
2 changed files with 6 additions and 3 deletions

View File

@ -23,12 +23,15 @@ class AccountBatchPayment(models.Model):
# First, try to use the journal's available payment methods
available_payment_methods = self.journal_id._get_available_payment_method_lines(self.batch_type)
payment_method_line = available_payment_methods.filtered(lambda x: x.code == 'direct_batch')
# Fix: Check payment_method_id.code, not just code
payment_method_line = available_payment_methods.filtered(lambda x: x.payment_method_id.code == 'direct_batch')
if not payment_method_line:
# If no direct batch payment method found, use the first available payment method
# If no direct batch payment method found, prefer 'manual' method for bank journals
if available_payment_methods:
payment_method_line = available_payment_methods[0]
# Try to find 'manual' payment method (most common for bank transfers)
manual_method = available_payment_methods.filtered(lambda x: x.payment_method_id.code == 'manual')
payment_method_line = manual_method[:1] if manual_method else available_payment_methods[0]
else:
# Fallback: try to find or create a direct batch payment method line
payment_method_line = self.env['account.payment.method.line'].search([