5.4 KiB
Fix Summary: "Missing required account on accountable line" Error
Problem
When creating a vendor payment with deductions, the system threw the error:
The operation cannot be completed: Missing required account on accountable line.
This occurred because Odoo validates that lines with payable/receivable accounts must have a partner_id set.
Root Cause
The issue had two parts:
-
Deduction lines were incorrectly getting
partner_id: All deduction lines were being created withpartner_id, but deduction accounts (like tax accounts) are typically NOT payable/receivable accounts and should NOT have a partner. -
Odoo's validation: When a line has a payable/receivable account type, Odoo requires the
partner_idfield. When a line has other account types (expense, liability, etc.), thepartner_idshould be optional or omitted.
Solution
Modified the _prepare_move_line_default_vals method to:
- Ensure counterpart line has partner: The payable/expense line (counterpart) always gets
partner_idset - Conditional partner on deduction lines: Only add
partner_idto deduction lines if the account type requires it
Code Change
Before:
deduction_line = {
'name': deduction_line_name,
'date_maturity': self.date,
'amount_currency': -deduction.amount_substract,
'currency_id': self.currency_id.id,
'debit': 0.0,
'credit': deduction_balance,
'partner_id': self.partner_id.id, # ❌ Always added
'account_id': deduction.substract_account_id.id,
}
After:
deduction_line = {
'name': deduction_line_name,
'date_maturity': self.date,
'amount_currency': -deduction.amount_substract,
'currency_id': self.currency_id.id,
'debit': 0.0,
'credit': deduction_balance,
'account_id': deduction.substract_account_id.id,
}
# Only add partner_id if the account requires it
if deduction.substract_account_id.account_type in ('asset_receivable', 'liability_payable'):
deduction_line['partner_id'] = self.partner_id.id # ✅ Conditionally added
Account Types
Accounts that REQUIRE partner_id:
asset_receivable(Customer accounts)liability_payable(Vendor accounts)
Accounts that DON'T need partner_id:
liability_current(Tax payable accounts like PPh 21, PPh 29)expense(Expense accounts)income(Income accounts)asset_cash(Bank accounts)- All other account types
Result
Now the journal entry is created correctly:
Example: Payment Rp 2,000,000 with PPh 21 (Rp 100,000) and PPh 29 (Rp 50,000)
Account | Debit | Credit | Partner
-------------------------------------|-----------------|-----------------|------------------
Accounts Payable | Rp 2,000,000.00 | | PT Telkom ✅
PPh 21 (Tax Payable) | | Rp 100,000.00 | (none) ✅
PPh 29 (Tax Payable) | | Rp 50,000.00 | (none) ✅
Bank Account | | Rp 1,850,000.00 | (none) ✅
-------------------------------------|-----------------|-----------------|------------------
TOTAL | Rp 2,000,000.00 | Rp 2,000,000.00 |
Key Points:
- ✅ Payable account has partner (required)
- ✅ Tax accounts don't have partner (correct)
- ✅ Bank account doesn't have partner (correct)
- ✅ Entry is balanced
- ✅ No validation errors
Testing
To test the fix:
-
Create a payment without expense account:
- Partner: Any vendor - Amount: 1000 - Deduction: PPh 21 - 100 (use a tax account) - Result: Should post successfully -
Create a payment with expense account:
- Partner: Any vendor - Amount: 2000 - Expense Account: Telepon & Internet - Deduction 1: PPh 21 - 100 - Deduction 2: PPh 29 - 50 - Result: Should post successfully -
Verify journal entries:
- Check that payable/expense line has partner
- Check that tax lines don't have partner
- Check that entry is balanced
Important Notes
Deduction Account Selection
When adding deductions, make sure to use the correct account types:
✅ Correct accounts for deductions:
- Tax payable accounts (PPh 21, PPh 23, PPh 29, etc.)
- Expense accounts (if recording as expense)
- Liability accounts (for other withholdings)
❌ Don't use these for deductions:
- Accounts Payable (vendor accounts)
- Accounts Receivable (customer accounts)
Why This Matters
Using payable/receivable accounts for deductions would create confusion:
- It would require a partner on the deduction line
- It would mix vendor payables with tax payables
- It would complicate reconciliation
- It's not the correct accounting treatment
Files Modified
-
models/account_payment.py- Added conditional
partner_idlogic for deduction lines - Ensured counterpart line always has
partner_id
- Added conditional
-
SCENARIOS.md- Updated validation rules
- Added explanation about partner_id handling
- Updated troubleshooting section
-
FIX_SUMMARY.md(this file)- Documented the fix and reasoning
Version
This fix is included in version 2.0.0 of the module.
Related Issues
- "Missing required account on accountable line" error
- Partner validation on journal entry lines
- Deduction account configuration
Credits
Fixed based on user feedback and testing with real-world scenarios.