我想创建日记帐分录,如果州=='打开',但是当我尝试我有这个问题时,你能帮我吗? 此代码在版本8中有效,但它不在版本11中。
def create_journal_entry(self):
move_pool = self.env['account.move']
move_line_pool = self.env['account.move.line']
name = "Advance payment: %s"%(self.employee_id.name)
debit_account_id = self.debit_id.id
credit_account_id = self.payment_method.id
#MOVE CREATE
move_data = {
'journal_id': self.payment_method.id,
'ref': name,
'company_id': self.company_id.id,}
move_id = move_pool.create(move_data)
#DEBIT LINE CREATE
debit_line = {
'move_id': move_id.id,
'name': name,
'partner_id': self.employee_id.address_home_id and \
self.employee_id.address_home_id.id or False,
'account_id': debit_account_id,
'debit': self.need_amount,
'credit': 0.0}
debit_line_id = move_line_pool.create(debit_line)
#CREDIT LINE CREATE
credit_line = {
'move_id': move_id.id,
'name': name,
'partner_id': self.employee_id.address_home_id and \
self.employee_id.address_home_id.id or False,
'account_id': credit_account_id,
'debit': 0.0,
'credit': self.need_amount}
credit_line_id = move_line_pool.create(credit_line)
return move_id
答案 0 :(得分:1)
代替创建单独的jo帐输入行,您必须设置借方和贷方行的vals,然后创建jo帐记录。这样可以解决您的问题