[FIX] account: right account on internal bank transfer
Steps to reproduce: - Create two bank journals Bank-1 and Bank-2 - Create one Oustanding Payments and one Outstanding Receipts account for each bank journal - Create and confirm an internal tranfer from Bank-1 to Bank-2 for 100$ - A second payment is created Issue: The account on the line in the second payment is the Outstanding Payments account of Bank-1, it should be the Outstanding Receipts account of Bank-2. After this commit, the second payment will take into account the account set on bank journal, and if not set, the one set on company. Otherwise, an error is raised. opw-2711252 closes odoo/odoo#81938 X-original-commit: 51b5a9d4e56d8d2300cf1ee91f8030c57a41a856 Signed-off-by: Laurent Smet <las@odoo.com> Signed-off-by: Guillaume Vanleynseele <guva@odoo.com>
This commit is contained in:
committed by
Laurent Smet
parent
147f99bb04
commit
ef1afc1502
@@ -54,7 +54,7 @@ class AccountPayment(models.Model):
|
||||
|
||||
# == Payment methods fields ==
|
||||
payment_method_line_id = fields.Many2one('account.payment.method.line', string='Payment Method',
|
||||
readonly=False, store=True,
|
||||
readonly=False, store=True, copy=False,
|
||||
compute='_compute_payment_method_line_id',
|
||||
domain="[('id', 'in', available_payment_method_line_ids)]",
|
||||
help="Manual: Pay or Get paid by any method outside of Odoo.\n"
|
||||
|
||||
@@ -852,3 +852,54 @@ class TestAccountPayment(AccountTestInvoicingCommon):
|
||||
'available_partner_bank_ids': self.comp_bank_account2.ids,
|
||||
'partner_bank_id': self.comp_bank_account2.id,
|
||||
}])
|
||||
|
||||
def test_internal_transfer_right_accounts(self):
|
||||
"""The purpose of this test is to check that the right accounts are computed when making an internal bank transfer"""
|
||||
|
||||
company = self.env.company
|
||||
transfer_account = company.transfer_account_id
|
||||
bank = self.bank_journal_1
|
||||
bank_2 = self.bank_journal_2
|
||||
|
||||
payment = self.env['account.payment'].create({
|
||||
'is_internal_transfer': True,
|
||||
'payment_type': 'outbound',
|
||||
'amount': 100.0,
|
||||
'journal_id': bank.id,
|
||||
'destination_journal_id': bank_2.id,
|
||||
})
|
||||
payment.action_post()
|
||||
|
||||
self.assertRecordValues(payment.line_ids, [
|
||||
{'account_id': company.account_journal_payment_credit_account_id.id},
|
||||
{'account_id': transfer_account.id},
|
||||
])
|
||||
self.assertRecordValues(payment.paired_internal_transfer_payment_id.line_ids, [
|
||||
{'account_id': company.account_journal_payment_debit_account_id.id},
|
||||
{'account_id': transfer_account.id},
|
||||
])
|
||||
|
||||
# We check the behavior when setting specific receipts/payments account on bank journals
|
||||
bank.inbound_payment_method_line_ids.payment_account_id = company.account_journal_payment_debit_account_id.copy({'code': 1001})
|
||||
bank.outbound_payment_method_line_ids.payment_account_id = company.account_journal_payment_credit_account_id.copy({'code': 1002})
|
||||
|
||||
bank_2.inbound_payment_method_line_ids.payment_account_id = company.account_journal_payment_debit_account_id.copy({'code': 2001})
|
||||
bank_2.outbound_payment_method_line_ids.payment_account_id = company.account_journal_payment_credit_account_id.copy({'code': 2002})
|
||||
|
||||
payment = self.env['account.payment'].create({
|
||||
'is_internal_transfer': True,
|
||||
'payment_type': 'outbound',
|
||||
'amount': 100.0,
|
||||
'journal_id': bank.id,
|
||||
'destination_journal_id': bank_2.id,
|
||||
})
|
||||
payment.action_post()
|
||||
|
||||
self.assertRecordValues(payment.line_ids, [
|
||||
{'account_id': bank.outbound_payment_method_line_ids.payment_account_id.id,},
|
||||
{'account_id': transfer_account.id},
|
||||
])
|
||||
self.assertRecordValues(payment.paired_internal_transfer_payment_id.line_ids, [
|
||||
{'account_id': bank_2.inbound_payment_method_line_ids.payment_account_id.id},
|
||||
{'account_id': transfer_account.id},
|
||||
])
|
||||
|
||||
Reference in New Issue
Block a user