Skip to content

Commit

Permalink
[FIX] account_payment_order: Filter bank on company
Browse files Browse the repository at this point in the history
  • Loading branch information
hhgabelgaard committed Jun 17, 2024
1 parent 768956f commit 62c4bc9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 5 additions & 2 deletions account_payment_order/models/account_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from odoo import api, fields, models
from odoo.fields import first


class AccountMoveLine(models.Model):
Expand Down Expand Up @@ -70,7 +69,11 @@ def _prepare_payment_line_vals(self, payment_order):
# in this case
if payment_order.payment_type == "outbound":
amount_currency *= -1
partner_bank_id = self.partner_bank_id.id or first(self.partner_id.bank_ids).id
partner_bank_id = self.partner_bank_id.id
if not partner_bank_id:
partner_bank_id = self.partner_id.bank_ids.filtered(
lambda bank: not bank.company_id or bank.company_id == self.company_id
)[:1].id
vals = {
"order_id": payment_order.id,
"partner_bank_id": partner_bank_id,
Expand Down
4 changes: 3 additions & 1 deletion account_payment_order/models/account_payment_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ def payment_line_hashcode(self):
def partner_id_change(self):
partner_bank = False
if self.partner_id.bank_ids:
partner_bank = self.partner_id.bank_ids[0]
partner_bank = self.partner_id.bank_ids.filtered(
lambda bank: not bank.company_id or bank.company_id == self.company_id
)[:1]
self.partner_bank_id = partner_bank

@api.onchange("move_line_id")
Expand Down

0 comments on commit 62c4bc9

Please sign in to comment.