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
- Knjigovodstvo
- Zaloga
- PoS
- Projekt
- MRP
This question has been flagged
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
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Prijavi| Related Posts | Odgovori | Prikazi | Aktivnost | |
|---|---|---|---|---|
|
|
1
jul. 25
|
1527 | ||
|
|
1
feb. 25
|
2809 | ||
|
|
1
maj 24
|
2083 | ||
|
|
0
nov. 23
|
4247 | ||
|
|
1
sep. 24
|
5335 |
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!