Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
5173 Lượt xem

Hi, Community and Master of Odoo

Please Help  me


I Have Custome Module named "Cash Advance" and I want to send/post  my data from Cash Advance to Journal Entries, which is you can do that on Invoice to post on Journal Entries automaticly.  Data will  be send to Journal Entries when state my data on the module approved.

My question is, what method  i need to do to send my data from my custom module to Journal Entries  just like Invoice to Journal Entries ?


Thanks Community please help me...

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,

If you are looking to create a journal entry you can directly call the create method of the corresponding model and pass the values into it.


Please see this sample code,

debit_vals = {
'name': self.reason,
'debit': abs(self.amount),
'credit': 0.0,
'account_id': self.debit_account_id.id,
'tax_line_id': adjustment_type == 'debit' and self.tax_id.id or False,
}
credit_vals = {
'name': self.reason,
'debit': 0.0,
'credit': abs(self.amount),
'account_id': self.credit_account_id.id,
'tax_line_id': adjustment_type == 'credit' and self.tax_id.id or False,
}
vals = {
'journal_id': self.journal_id.id,
'date': self.date,
'state': 'draft',
'line_ids': [(0, 0, debit_vals), (0, 0, credit_vals)]
}
move = self.env['account.move'].create(vals)


Thanks

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 5 24
6042
5
thg 3 20
12440
3
thg 1 18
3001
1
thg 12 22
4325
1
thg 5 18
4851