Hi,
We are considering using Odoo for reporting purposes, and I'm doing some proof of concept tests right now. Basically, we need to create some journal entries by using the external API and Python. The ultimate goal is to integrate this with our Python based application. I'm using Odoo v11.
I've figured out how to create the journal entry and also journal items - however as soon as I enter a credit or debit balance when creating the item I receive the following error:-
Fault: <Fault 2: 'Cannot create unbalanced journal entry.'>
My very basic code is below. If I run this as-is, it creates the journal entry. However, as soon as I uncomment the credit or debit balances, I receive the error above.
I guess I need a way to create the three lines simultaneously, or alternatively temporarily disable the control preventing the unbalanced entry. (The journal entry will balance after the final entry)
# Create journal entry
je_id = models.execute_kw(db, uid, password, 'account.move', 'create',
[{'name': "Python Journal Entry 2", 'date' : '06-Mar-2018', 'journal_id': '3'}])
# Create three lines - debit AR, Credit sales & tax
l1 = models.execute_kw(db, uid, password, 'account.move.line', 'create',
[{
'move_id': je_id,
'account_id': 7, #Receivables
# 'debit' : 120.00
}])
l2 = models.execute_kw(db, uid, password, 'account.move.line', 'create',
[{'move_id': je_id,
'account_id': 17, #Revenue
# 'credit' : 100.00
}])
l3 = models.execute_kw(db, uid, password, 'account.move.line', 'create',
[{'move_id': je_id,
'account_id': 14, #Tax
# 'credit' : 20.00
}])
Appreciate any advice that can be given.
George