Im Trying to Append 2 Journal Entry lines Regarding Bank charges(1 to Bank Charges(debit) and 2 to Bank(credit)) in the same Journal While Creating a Register Payment, I've Done in the Odoo13 And its totally working but when i tried in Odoo14 The following error is coming,
User Error
The journal entry Draft Entry (* 101) (INV/2021/04/0018) reached an invalid state relative to its payment. To be consistent, the journal entry must always contains:
- one journal item involving the outstanding payment/receipts account.
- one journal item involving a receivable/payable account.
- optional journal items, all sharing the same account.
_inherit = 'account.payment'
def _prepare_move_line_default_vals(self, write_off_line_vals=None):
res = super(AccountPaymentInherit, self)._prepare_move_line_default_vals()
debit_line = {'name': 'Test Journal Entry Creation',
'debit': 0.0, 'credit': 0.0, 'partner_id': 3,
'account_id': 7, 'payment_id': self.id}
credit_line = {'name': 'Test `Journal Entry Creation',
'debit': 0.0, 'credit': 0.0, 'partner_id': 3, 'account_id': 79, 'payment_id': self.id}
res.append(debit_line)
res.append(credit_line)
return res
I tried super the move_line preparation function and tried to append the lines ive created to it , But there is a condition in the account.payment as following
if len(liquidity_lines) != 1 or len(counterpart_lines) != 1:
raise UserError(_(
"The journal entry %s reached an invalid state relative to its payment.\n"
"To be consistent, the journal entry must always contains:\n"
"- one journal item involving the outstanding payment/receipts account.\n"
"- one journal item involving a receivable/payable account.\n"
"- optional journal items, all sharing the same account.\n\n"
) % move.display_name)