diff --git a/models/__pycache__/account_batch_payment.cpython-312.pyc b/models/__pycache__/account_batch_payment.cpython-312.pyc index e4d1f6d..0e3842f 100644 Binary files a/models/__pycache__/account_batch_payment.cpython-312.pyc and b/models/__pycache__/account_batch_payment.cpython-312.pyc differ diff --git a/models/account_batch_payment.py b/models/account_batch_payment.py index 116962c..88992eb 100644 --- a/models/account_batch_payment.py +++ b/models/account_batch_payment.py @@ -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([