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

[IMP] Use the partner to find the bank account (for reconciliation) #59

Open
wants to merge 1 commit into
base: 14.0-relax-bank-account-unique-constraint-sbi
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion addons/account/models/account_bank_statement.py
Original file line number Diff line number Diff line change
Expand Up @@ -1283,7 +1283,9 @@ def reconcile(self, lines_vals_list, to_check=False):

def _find_or_create_bank_account(self):
bank_account = self.env['res.partner.bank'].search(
[('company_id', '=', self.company_id.id), ('acc_number', '=', self.account_number)])
[('company_id', '=', self.company_id.id),
('acc_number', '=', self.account_number),
('partner_id', '=', self.partner_id.id)])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is self.partner_id always known at this stage ? I've not looked in details but I know scenarios (e.g. CODA files import) where the account number is used to find the partner.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes the partner_id is always known at this stage.
The only call to that method is this:
if self.account_number and self.partner_id and not self.partner_bank_id: self.partner_bank_id = self._find_or_create_bank_account()

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are maybe other places where Odoo is looking for bank account without using the partner but I only fix the issue on the reconciliation widget provided by Odoo.

if not bank_account:
bank_account = self.env['res.partner.bank'].create({
'acc_number': self.account_number,
Expand Down