[FIX] account: payment wizard available journals with one payment type

Create an invoice to partner A, confirm
Create an invoice to partner B, confirm
From Invoice list view, select just one invoice and hit register payment
It will be possible to only select journals having inbound payment
method
Now select both invoices and hit register payment
It will be possible to select any Bank journal, even if both invoice
payments should be incoming

opw-3757686

closes odoo/odoo#157732

X-original-commit: 88f43a454f3cd9207aa62e2e58b67bcfdf0fcb59
Signed-off-by: Laurent Smet (las) <las@odoo.com>
Signed-off-by: Andrea Grazioso (agr) <agr@odoo.com>
This commit is contained in:
Andrea Grazioso (agr-odoo)
2024-03-15 10:43:53 +00:00
parent 114f09ba98
commit e9bdb99124
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from collections import defaultdict
from odoo import models, fields, api, _
from odoo import Command, models, fields, api, _
from odoo.exceptions import UserError
from odoo.tools import frozendict
@@ -418,14 +418,10 @@ class AccountPaymentRegister(models.TransientModel):
@api.depends('payment_type', 'company_id', 'can_edit_wizard')
def _compute_available_journal_ids(self):
for wizard in self:
if wizard.can_edit_wizard:
batch = wizard._get_batches()[0]
wizard.available_journal_ids = wizard._get_batch_available_journals(batch)
else:
wizard.available_journal_ids = self.env['account.journal'].search([
*self.env['account.journal']._check_company_domain(wizard.company_id),
('type', 'in', ('bank', 'cash')),
])
available_journals = self.env['account.journal']
for batch in wizard._get_batches():
available_journals |= wizard._get_batch_available_journals(batch)
wizard.available_journal_ids = [Command.set(available_journals.ids)]
@api.depends('available_journal_ids')
def _compute_journal_id(self):