Skip to content
Snippets Groups Projects
Commit 053a6eb1 authored by Mylyna Hy's avatar Mylyna Hy
Browse files

[FIX] account: fix payment to own company via expense

Expense - Steps to reproduce the bug:
1. Create an employee whose private address is linked to the current company's partner_id
2. Create an Expense and expense report with the employee(1) with mode paid by employee
3. Confirm the Expense report and post the journal entries
4. Click "Register Payment" --> User Error occurs
5. A User Error like the following should appear (with different journal entry names):
       "Journal Entry Draft Entry PBNK1/2023/00001 (INV/2023/00005) is not valid. In order to proceed, the journal items must include one and only one receivable/payable account (with an exception of internal transfers)."

The User Error also occurs for a different scenario mentioned in https://github.com/odoo/odoo/pull/127412



According to SVFU on how the bug is fixed:
The condition that classifies the extra lines as "counterpart lines" was only intended for internal transfers.
Each company has a related "transfer account" that is used as an intermediary account for internal transfers.
Thus the old condition (c.f. commit diff) when checking whether a line is a "counterpart line"
can be replaced by checking whether the account associated with the line is the "transfer account" of our company.

closes odoo/odoo#128645

Signed-off-by: default avatarLaurent Smet (las) <las@odoo.com>
parent 5f0ac1ae
Branches
Tags
No related merge requests found
......@@ -168,7 +168,7 @@ class AccountPayment(models.Model):
self.journal_id.payment_credit_account_id,
):
liquidity_lines += line
elif line.account_id.internal_type in ('receivable', 'payable') or line.partner_id == line.company_id.partner_id:
elif line.account_id.internal_type in ('receivable', 'payable') or line.account_id == line.company_id.transfer_account_id:
counterpart_lines += line
else:
writeoff_lines += line
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment