Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ def setUpClass(cls):
"name": "BANK",
"type": "bank",
"code": "bank",
"bank_acc_number": "123456",
}
)
cls.journal_bank.bank_account_id.with_user(
cls.env.ref("base.user_admin")
).allow_out_payment = True
payment_form = Form(cls.env["account.payment.mode"])
payment_form.name = "SEPA (CORE)"
payment_form.payment_method_id = cls.method_sepa
Expand Down
18 changes: 11 additions & 7 deletions account_banking_sepa_credit_transfer/tests/test_sct.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,17 @@ def setUpClass(cls):
"name": "Test Partner 1",
}
)
cls.partner_bank_1 = cls.env["res.partner.bank"].create(
{
"acc_number": "FR66 1212 1212 1212 1212 1212 121",
"bank_id": cls.bank.id,
"partner_id": cls.partner_1.id,
"allow_out_payment": True,
}
cls.partner_bank_1 = (
cls.env["res.partner.bank"]
.with_user(cls.env.ref("base.user_admin"))
.create(
{
"acc_number": "FR66 1212 1212 1212 1212 1212 121",
"bank_id": cls.bank.id,
"partner_id": cls.partner_1.id,
"allow_out_payment": True,
}
)
)
cls.partner_2 = cls.env["res.partner"].create(
{
Expand Down
25 changes: 19 additions & 6 deletions account_payment_partner/tests/test_account_payment_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ def setUpClass(cls):
"bank_acc_number": "123456",
}
)
# Use admin user as the SUPERUSER is not allowed to
# modify allow_out_payment on bank accounts and this
# is needed to avoid error when posting the invoice
cls.journal_c1.bank_account_id.with_user(
cls.env.ref("base.user_admin")
).allow_out_payment = True

cls.journal_c2 = cls.journal_model.create(
{
Expand Down Expand Up @@ -247,7 +253,10 @@ def test_partner_id_changes_compute_partner_bank(self):
move_form = Form(
self.env["account.move"].with_context(default_move_type="out_invoice")
)
self.assertFalse(move_form.partner_bank_id)
# The partner bank should be set as Odoo made possible
# to assign not allow_out_payment bank account
# more info https://github.com/odoo/odoo/commit/1794fce234735ed174599891435d4e2accc16324
self.assertTrue(move_form.partner_bank_id)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why is this and the next ones changing? We want to not have a bank account assigned. Maybe you need to change the parameter at company level, or test both.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Because the bank_partner in this case YourCompany has the bank_ids created with demo data https://github.com/OCA/bank-payment/blob/17.0/account_payment_mode/demo/payment_demo.xml#L36, before the change those banks account were not allowed so none of them get selected now it takes de first one https://github.com/odoo/odoo/blob/17.0/addons/account/models/account_move.py#L897

move_form.partner_id = self.customer
self.assertEqual(move_form.payment_mode_id, self.customer_payment_mode)
self.assertFalse(move_form.partner_bank_id)
Expand All @@ -262,12 +271,13 @@ def test_out_invoice_onchange(self):
}
)
self.assertEqual(invoice.payment_mode_id, self.customer_payment_mode)

invoice.company_id = self.company_2
self.assertEqual(invoice.payment_mode_id, self.payment_mode_model)

prev_partner_bank_id = invoice.partner_bank_id.id
invoice.payment_mode_id = False
self.assertFalse(invoice.partner_bank_id)
# Without the check keep_partner_bank_without_payment_mode on company
# the partner bank should remain the same
self.assertEqual(invoice.partner_bank_id.id, prev_partner_bank_id)

def test_invoice_create_in_invoice(self):
invoice = self._create_invoice(
Expand Down Expand Up @@ -411,7 +421,8 @@ def test_invoice_in_refund(self):
refund_invoice.payment_mode_id,
invoice.payment_mode_id.refund_payment_mode_id,
)
self.assertEqual(refund_invoice.partner_bank_id, invoice.partner_bank_id)
# Now the partner_bank_id can be a not allow_out_payment bank account
self.assertTrue(refund_invoice.partner_bank_id)

def test_invoice_out_refund(self):
invoice = self._create_invoice(
Expand Down Expand Up @@ -477,7 +488,9 @@ def test_partner_onchange(self):
self.assertFalse(invoice.partner_bank_id)
vals = {"partner_id": False, "move_type": "in_refund"}
invoice = self.move_model.new(vals)
self.assertFalse(invoice.partner_bank_id)
# The partner bank should be set as odoo made posible
# to assign not allow_out_payment bank accounts
self.assertTrue(invoice.partner_bank_id)

def test_onchange_payment_mode_id(self):
mode = self.supplier_payment_mode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ def test_no_account_default_in_invoice(self):
self.assertFalse(in_invoice.partner_bank_id)

def test_no_payment_mode(self):
# Test no bank account if bank_account is not required in payment mode
# Test bank account remains the same if no payment mode
self.partner_a.default_bank_id = self.bank_account2
self.partner_a.supplier_payment_mode_id = False
in_invoice = self.create_in_invoice()
self.assertFalse(in_invoice.partner_bank_id)
self.assertEqual(in_invoice.partner_bank_id, self.bank_account1)

def test_commercial_fields(self):
# Test the default partner account in vendor bills with individual partner
Expand Down