Quick overview
This workflow receives employee expense submissions via a webhook, validates the payload, creates an expense in Odoo, and immediately acknowledges the request. It then sends a Slack approval form to managers and, based on the decision, updates the Odoo expense status and notifies the employee via Gmail.
How it works
- Receives an expense submission via a POST webhook and normalizes fields like employee, vendor, amount, category, description, and receipt details.
- Validates required fields and returns a 400 JSON response if the submission is incomplete or invalid.
- Looks up the employee in Odoo (hr.employee) and returns a 404 JSON response if no matching employee record is found.
- Looks up the expense category in Odoo (product.product) and creates an expense record in Odoo (hr.expense), returning a 202 JSON response with the created expense ID.
- Posts a Slack message to the #expense-approvals channel with a custom approval form and waits up to two days for a manager decision.
- If approved, updates the Odoo expense state to approved and emails the employee via Gmail; otherwise, marks the expense refused with the manager comment and emails the employee to resubmit.
Setup
- Create an Odoo API credential with access to hr.employee, product.product, and hr.expense, and verify your Odoo schema supports the mapped fields (for example, unit_amount and payment_mode).
- Add a Slack credential with permission to post to #expense-approvals (or change the channel) and use interactive messages to collect the approval decision and comment.
- Add a Gmail OAuth credential and ensure the workflow can email employees using the submitted employeeEmail field.
- Copy the production webhook URL and configure your expense form/app to POST the expected JSON fields (employeeName/employeeEmail, vendor, amount, currency, category, description, and receiptUrl).