Odoo 18: Soft validation with “Continue or Cancel” when changing CRM stage?
I’m have a custom CRM workflow in Odoo and I’m trying to find the most Odoo-native way to implement a “soft warning” on `crm.lead` stage changes.
I have some dynamic requirements (checklists) associated with opportunities and stages. When a user tries to move an opportunity out of its current stage before completing the requirements for that stage, I would like to show a confirmation dialog along the lines of:
> You have not completed all requirements for the current stage. Do you want to continue moving this opportunity anyway?
The desired behavior is:
- If the user clicks **Cancel**, the stage change is reverted.
- If the user clicks **Continue**, the stage change proceeds.
- I do **not** want to completely block the save in all cases.
- I want this to apply when changing `stage_id` on `crm.lead`, ideally including normal form usage and possibly kanban stage changes.
The approaches I’ve considered:
`@api.onchange("stage_id")`
This can detect the stage change and return a warning, but it does not seem to provide a clean “Continue / Cancel” interaction. I could revert the field in the onchange, but that is more of a hard reset than a confirmation flow.
Override `write()`
This is good for hard enforcement because I can raise a `UserError`, but that does not give the user an option to proceed. I could use context flags to bypass the check, but then I still need a clean UI path to set that context after confirmation.
Custom button / wizard
I could replace free stage changes with a custom “Move Stage” action that opens a wizard when requirements are incomplete. This seems more controllable, but it feels heavier and may not integrate well with normal CRM kanban dragging (which is what people tend to use)
Custom JS patch
I suspect the exact behavior may require patching the CRM form/kanban stage-change behavior in JavaScript, calling a server method to check requirements, and then showing a confirmation dialog before allowing the write. I’m trying to understand whether this is the expected approach or overkill. It seems like too much.
Is there an Odoo-recommended pattern for this kind of “soft validation with user confirmation” on field changes?
In other words: not a hard validation error, but a conditional “Are you sure?” dialog before allowing a `stage_id` change on `crm.lead`.
I’m especially interested in how people handle this in Odoo 17/18 with the modern web client / OWL framework. I’m hoping to avoid a large or brittle custom OWL patch/component if possible. This is meant to be a lightweight workflow nudge, not a full custom stage-change mechanism. Has anyone implemented something like this in a reasonably maintainable way?