Collections Next Action AI
Show live dunning ladder next-action suggestions on every collections case, respect active promises to pay, and optionally enrich the reasoning with an LLM.
Why this module
Collections Next Action AI
Computed fields, never stale
The suggestion is a non-stored computed field, so it recomputes on every read and always reflects the live case state (days overdue, promises, contacts) without a refresh cron or manual refresh button.
Active promise suppresses escalation
An active promise to pay always routes the case to monitor mode, regardless of how many days overdue it is, so collectors never chase a partner who has committed to pay on a known date.
Deterministic by default, rich if you want it
The eight-rule dunning ladder runs with zero API keys and zero network access. Configure an AI provider on the company and the same hook sends the case snapshot to your provider for a richer narrative, falling back to the deterministic action on any error or bad key.
Day in the life
A collector opens a case and sees the next step
A collector opens an overdue case at 95 days, with one email sent and no response. The case form shows AI Next Action tab with the suggested action (send_demand_letter), priority (high), and a plain-English rationale. The company has no AI provider configured, so the rationale is the deterministic one explaining the 90-day threshold and formal demand letter reason. The collector sends the demand letter. Later, the same case at 130 days shows refer_to_collections_agency because enough time has passed since the letter. If the collector logs a promise to pay (e.g. payment due in 30 days), the next read flips the suggestion to monitor (low priority) because the active promise suppresses further escalation.
Edge cases
The cases most modules quietly ignore.
In the shipped code today, each one a place where a cheaper module silently does the wrong thing.
An active promise to pay (promise_date in the future) always suppresses escalation, no matter how many days overdue. A lapsed promise (promise_date passed) immediately escalates to manager review. A promise can only suppress escalation while active; once the date passes, the case returns to the normal dunning ladder.
The suggestion detects whether a demand letter has been sent by scanning the action log for any action_type='letter'. Agency referral only triggers at 120+ days when this flag is true, enforcing a legal escalation sequence.
The suggestion counts contact attempts from the action log (actions with contact_made=True). No contacts triggers first-contact email at 30+ days; prior contact triggers phone call at 45+ days. A fresh contact attempt resets the escalation path.
Any case state that does not match the eight rules (e.g. under 30 days with no contact, or between thresholds) routes to manual_review so a collector applies their judgment rather than a forced action.
If the company configures an AI provider but that provider fails, raises a bad-credential error, or returns malformed JSON, the module silently returns the deterministic suggestion instead of breaking the case form.
What is inside
Built to do the job, end to end.
- models/collections_case.py. EhCollectionsCase model extends eh.collections.case with three computed fields: eh_ai_suggested_action (string), eh_ai_suggested_priority (selection: low/medium/high), and eh_ai_suggestion_rationale (text). All depend on days_overdue_max, total_overdue_amount, has_active_promise, broken_promise, and action_ids. The _compute_eh_ai_suggestion method calls next_action_suggester.suggest() with a CaseSnapshot and the company's provider key and config. The _eh_build_case_snapshot method maps the case state to the transport record.
- next_action_suggester (eh_account_ai_agent/tools). The core Odoo-independent engine implementing the eight-rule deterministic dunning ladder. CaseSnapshot is a dataclass carrying days_overdue, total_overdue, contact_count, promise flags, action type and recency, demand letter flag, payment plan flag, and customer segment. The suggest() function invokes _deterministic_suggest() and optionally _augment_via_llm() if a provider is configured. All provider errors are caught and the deterministic suggestion is returned unchanged.
- views/collections_case_views.xml. Inherited form view for eh.collections.case. Adds an 'AI Next Action' tab with three read-only fields (eh_ai_suggested_action, eh_ai_suggested_priority, eh_ai_suggestion_rationale), a Refresh AI Suggestion button to invalidate cached fields on demand, and help text explaining deterministic operation and optional LLM enrichment.
- tests/test_case_suggestion.py. Integration tests verifying the live wiring of the dunning ladder. Tests cover active promise suppresses escalation, broken promise escalates, write-off at 200 days, demand letter at 90+ days, agency referral after letter, first contact email at 30+ days, phone call after contact, recomputation on state change, and demand letter detection from action log.
Honest about the edges
What this does not do, so nothing surprises you.
- This module does not execute any action on your behalf. It suggests a next step; the collector or an automation decides whether to follow it.
- The deterministic dunning ladder is fixed to eight rules and cannot be configured per company or case type. Custom escalation paths would require forking the next_action_suggester.
- The LLM augmentation depends on the company configuring a valid AI provider key and config on the AI agent layer (eh_account_ai_agent). If no provider is configured, only the deterministic suggestion is shown.
- Promise-to-pay state is derived from action log entries with promise_amount and promise_date set by the collector. The module does not enforce or validate promises; it only reads what the collector has logged.
- Demand letter detection relies on action log entries with action_type='letter'. If a letter is sent outside Odoo, the collector must log it manually so the escalation ladder tracks it correctly.
collections next action, dunning ladder Odoo, promise to pay, collections automation, Odoo collections case, demand letter routing, agency referral escalation, write-off guidance, collections case management, deterministic escalation, contact attempt tracking, collections priority, overdue case routing, Odoo 19 collections, broken promise handling
Languages
Available in 19 languages
The interface ships translated out of the box. Switch language in Odoo and the fields, menus, and messages follow.
Please log in to comment on this module