콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
7 답글
6658 화면

Hello Community,

Recently I have been trying to create vendor bills in odoo13 by code by apparently every time I run the code I get a message "Cannot create unbalanced journal entry. Ids: [177] Differences debit - credit: [3.5]"

3.5 in my unit_price.

My code is below:

payment_move = self.env['account.move'].create({
'type': 'in_invoice',
'partner_id': self.client.id,
})
payment_move.invoice_line_ids.create({'move_id': payment_move.id,
'quantity': 1.0,
'price_unit': 3.5,
'account_id': self.env['account.account'].search(
[('user_type_id', '=', self.env.ref('account.data_account_type_expenses').id)], limit=1).id})

Thanks in advance.

아바타
취소
베스트 답변

This may help

Create invoices/credit notes in odoo13 by code

아바타
취소

hello paresh wagh can you share your answer here i think your link can't find page.

Thank You in advance.

The link seems to be working fine. It's a link to another thread where this same topic was discussed.

@Paresh i also check and link don't work :(

Pasting the link here since there are multiple posts in the thread that provide contextual information.

https://www.odoo.com/forum/help-1/question/create-invoices-credit-notes-in-odoo13-by-code-163575#answer-163579

If this does not work, please report an issue with Odoo at

https://github.com/odoo/odoo/issues

베스트 답변

See That works fine for me. 

This is becuse you are giving just one entry for example debit or credit you must do two entries with same amount like that.

'line_ids': [
(0, 0, {
'account_id': account,
'debit': sale_orders[0].charger_id,
}),
(0, 0, {
'account_id': account_other,
'credit': sale_orders[0].charger_id,
}),

I created below invoice too. I hope this will help you too.
def _prepare_invoice_values(self, order, name, amount, so_line):
invoice_line = super(VisioJournalItem, self)._prepare_invoice_values(order, name, amount, so_line)
account_a = self.env.ref('visio_chargers_journal_item.visio_b_dividends').id
account_id = self.env.ref('visio_chargers_journal_item.visio_a_dividends').id
account_o = self.env.ref('visio_chargers_journal_item.visio_c_dividends').id



sale_orders = self.env['sale.order'].browse(self._context.get('active_ids', []))
order = sale_orders[0]
so_line = order.order_line[0]
line1= {
'name': 'Freight Charger',
'price_unit': order.charger_id,
'account_id': account_id,
'exclude_from_invoice_tab': True,

}
line2 = {
'name': 'Insurance Amount',
'price_unit': order.insurance_amount_id,
'account_id': account_a,
'exclude_from_invoice_tab': True,

}
line3 = {
'name': 'Tax Amount NTN',
'price_unit': order.tax_id,
'account_id': account_o,
'exclude_from_invoice_tab': True,
}
lines = [line1, line2, line3]
for line in lines:
line['quantity'] = 1.0
line['sale_line_ids'] = [(6, 0, [so_line.id])]
line['analytic_tag_ids'] = [(6, 0, so_line.analytic_tag_ids.ids)]
line['analytic_account_id'] = order.analytic_account_id.id or False

invoice_line['invoice_line_ids'].append(line)

return invoice_line

Regards

MUHAMMAD IMRAN
Technical and Functional Consultant  (ODOO)


Softtar Technologies Pvt. Ltd. Contact : Pakistan (+92)-3037701373
 
Address:
  
Allhafeez Shopping Mall
Lahore
Pakistan  (Branch Office)
http://sofftar.com
아바타
취소
베스트 답변
See how I handle invoice_line_ids below:

            invoice_move = self.env['account.move'].create({
                'type''out_invoice',
                'partner_id': client_partner_id_variable,
            })
            invoice_move.write({
                'invoice_line_ids': [(00, {
                    'move_id': invoice_move.id,
                    'quantity'1.0,
                    'price_unit'3.5,
                    'account_id'self.env['account.account'].search( [('user_type_id''='self.env.ref('account.data_account_type_expenses').id)], limit=1 ).id
                 })]
            })
아바타
취소
관련 게시물 답글 화면 활동
2
12월 24
4484
1
11월 24
3261
2
4월 23
18302
1
3월 23
2489
4
8월 24
24390