Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX][CL] Keep selected account #3089

Open
wants to merge 5 commits into
base: 16.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions sale_order_type/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
from . import res_partner
from . import account_move
from . import res_currency
from . import account_payment
24 changes: 24 additions & 0 deletions sale_order_type/models/account_payment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from odoo import api, models


class AccountPayment(models.Model):
_inherit = "account.payment"

@api.depends("available_partner_bank_ids", "journal_id")
def _compute_partner_bank_id(self):
"""
If the selected account is in the available accounts then the change is not made.
"""
partner_bank_by_pay = {}
for payment in self:
partner_bank_by_pay[payment.id] = payment.partner_bank_id
res = super(AccountPayment, self)._compute_partner_bank_id()
for payment in self:
if (
partner_bank_by_pay.get(payment.id, False)
and partner_bank_by_pay.get(payment.id)
in payment.available_partner_bank_ids
):
payment.partner_bank_id = partner_bank_by_pay.get(payment.id)

return res