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
- Kirjanpito
- Varastointi
- PoS
- Projekti
- MRP
Tämä kysymys on merkitty
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
Nautitko keskustelusta? Älä vain lue, vaan osallistu!
Luo tili jo tänään nauttiaksesi yksinoikeusominaisuuksista ja osallistuaksesi mahtavaan yhteisöömme!
Rekisteröidy| Aiheeseen liittyviä artikkeleita | Vastaukset | Näkymät | Toimenpide | |
|---|---|---|---|---|
|
|
1
heinäk. 25
|
1527 | ||
|
|
1
helmik. 25
|
2809 | ||
|
|
1
toukok. 24
|
2084 | ||
|
|
0
marrask. 23
|
4248 | ||
|
|
1
syysk. 24
|
5338 |
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!