Skip to content

Commit

Permalink
Merge PR #1237 into 15.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Nov 25, 2024
2 parents 8c8b82d + 62c4bc9 commit 5ed0536
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 5ed0536

Please sign in to comment.