fix journal movement
This commit is contained in:
parent
3c9a910d8f
commit
822ed95c53
Binary file not shown.
@ -23,12 +23,15 @@ class AccountBatchPayment(models.Model):
|
|||||||
|
|
||||||
# First, try to use the journal's available payment methods
|
# First, try to use the journal's available payment methods
|
||||||
available_payment_methods = self.journal_id._get_available_payment_method_lines(self.batch_type)
|
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 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:
|
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:
|
else:
|
||||||
# Fallback: try to find or create a direct batch payment method line
|
# Fallback: try to find or create a direct batch payment method line
|
||||||
payment_method_line = self.env['account.payment.method.line'].search([
|
payment_method_line = self.env['account.payment.method.line'].search([
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user