Hello everyone, I would like to ask for your help in implementing a cash advance sort of system where an employee can request via approvals module a cash advance. Then when it gets approved it will generate a journal entry and/or a bill for the accounting department.
I tried automation in odoo studio but no journal entry is being created and bills is also not created.
I hope someone can help. Thank you!
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Kế toán
- Tồn kho
- PoS
- Dự án
- MRP
Câu hỏi này đã bị gắn cờ
models/cash_advance_request.py
request.journal_entry_id = move.id
Hope it helps
1. Create the Approval Type
Go to Approvals → Configuration → Approval Types → Create
Name: Cash Advance Request
Add fields: Employee, Amount, Purpose
Set approvers (Manager / Finance)
2. Create an Automated Action
Go to:
Settings → Technical → Automation → Automated Actions → Create
Set:
Model: Approvals Request
Trigger: On Update
Condition: state == 'approved'
Action: Execute Python Code
3. Paste This Code (for Journal Entry)
employee = record.employee_id
amount = record.amount or 0.0
journal = env['account.journal'].search([('type', '=', 'cash')], limit=1)
advance_account = env['account.account'].search([('code', '=', '141000')], limit=1)
cash_account = env['account.account'].search([('code', '=', '100000')], limit=1)
move_vals = {
'journal_id': journal.id,
'ref': f"Cash Advance - {employee.name}",
'line_ids': [
(0, 0, {'account_id': advance_account.id, 'name': 'Advance', 'debit': amount}),
(0, 0, {'account_id': cash_account.id, 'name': 'Cash Out', 'credit': amount}),
]
}
move = env['account.move'].create(move_vals)
move.action_post()
4. Test
Submit a cash advance request
Approve it
Check Accounting → Journal Entries
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng ký| Bài viết liên quan | Trả lời | Lượt xem | Hoạt động | |
|---|---|---|---|---|
|
|
1
thg 7 25
|
1536 | ||
|
|
1
thg 2 25
|
2818 | ||
|
|
1
thg 5 24
|
2094 | ||
|
|
0
thg 11 23
|
4258 | ||
|
|
1
thg 9 24
|
5360 |
Hello, Thank you for this. But this is where I get blocked by the problem, nothing is created in the journal entries even though I followed your instructions.
I hope you can help me further, Thank you!