[FIX] account: prevent traceback while no payment method is selected

When we create a journal and it gets one of the payment method's value as
False and we input another payment method. it will give an error with the
 message -

'sequence item 0: expected str instance, bool found'

Steps to Produce:-

1. Go to Accounting then configuration
2. Click on 'Journals' under Accounting
3. Create or click on exiting one
4. Input all required fields and select 'Type' as Cash or Bank
5. Delete value of one of either incoming payments or outgoing payments
6. Click on save
7. Remove name of one of the payment method and input other

Trace-back will be generated.

Applying these changes will resolve this issue.

closes odoo/odoo#124739

X-original-commit: 1e242de53a5bbb2e1eed50504be0649775b9db47
Signed-off-by: Laurent Smet <las@odoo.com>
This commit is contained in:
Preksha Chouhan
2023-06-13 08:44:11 +02:00
parent ee6e560415
commit c9babef3c8
+1 -1
View File
@@ -342,7 +342,7 @@ class AccountJournal(models.Model):
These will be then used to display or not payment method specific fields in the view.
"""
for journal in self:
codes = [line.code for line in journal.inbound_payment_method_line_ids + journal.outbound_payment_method_line_ids]
codes = [line.code for line in journal.inbound_payment_method_line_ids + journal.outbound_payment_method_line_ids if line.code]
journal.selected_payment_method_codes = ',' + ','.join(codes) + ','
@api.depends('company_id', 'type')