Skip to content

[19.0][IMP] subscription_oca: pause and resume subscriptions#1470

Open
alvaro-domatix wants to merge 1 commit into
OCA:19.0from
alvaro-domatix:19.0-imp-subscription_oca-pause-resume
Open

[19.0][IMP] subscription_oca: pause and resume subscriptions#1470
alvaro-domatix wants to merge 1 commit into
OCA:19.0from
alvaro-domatix:19.0-imp-subscription_oca-pause-resume

Conversation

@alvaro-domatix

Copy link
Copy Markdown

Adds the ability to pause and resume a subscription without closing it.

A tracked is_paused flag (with an optional paused_until date) is added to sale.subscription. The recurring cron honours the flag: it runs a dedicated resume helper first (auto-resuming any subscription whose paused_until has been reached), then short-circuits on is_paused so paused contracts are neither invoiced nor auto-closed by date.

action_pause raises on closed or already-paused contracts and optionally schedules a resume date; action_resume reactivates the subscription manually. Both post a chatter line. A Pause wizard lets the user set the resume date from the UI, and a yellow banner shows the paused state (and the scheduled resume date) on the form.

Purely additive: it does not touch stage_id semantics or the stage machine, so installations with custom stages keep working unchanged.

Note for reviewers: this PR edits the cron_subscription_management method, which #1442 also refactors into sub-methods. They need to be reconciled; ideally #1442 lands first and the is_paused guard is then re-introduced into _cron_invoice_due_subscriptions (plus the resume helper at the top of cron_subscription_management). The reconciliation is already proven in the testing integration branch.

@alvaro-domatix alvaro-domatix force-pushed the 19.0-imp-subscription_oca-pause-resume branch 2 times, most recently from 19abf60 to 37024dc Compare June 25, 2026 18:27
Add a Boolean `is_paused` (with optional `paused_until` date) on
`sale.subscription` so a subscription can be put on hold without
closing it. The recurring cron honours the flag and skips paused
subscriptions; if `paused_until` is in the past it auto-resumes them
in a dedicated helper that the cron runs before the main loop.

* `is_paused` Boolean (tracked, partial index).
* `paused_until` Date (tracked).
* `action_pause(paused_until=None)` — raises on closed or
  already-paused contracts, posts a chatter line with the resume date
  if any.
* `action_resume(automatic=False)` — raises if not paused, posts a
  chatter line; the `automatic` flag changes the wording when the
  resume is triggered by the cron helper.
* `_cron_resume_due_subscriptions(limit=None)` — searches paused subs
  with `paused_until <= today` and resumes them.
* `cron_subscription_management` calls the resume helper first and
  then short-circuits on `is_paused` so paused contracts are never
  invoiced nor auto-closed by date.

UI:

* Header buttons "Pause" and "Resume".
* Yellow alert banner in the sheet while paused, showing the resume
  date if scheduled.
* Search filters "Paused" and "Active and not paused".

This does not touch `stage_id` semantics or the existing stage
machine, so installations with custom stages keep working unchanged.
Pure additive migration: `-u subscription_oca` adds the two columns
with their `False` defaults.
@alvaro-domatix alvaro-domatix force-pushed the 19.0-imp-subscription_oca-pause-resume branch from 37024dc to 264c24b Compare June 25, 2026 18:33
@OCA-git-bot

Copy link
Copy Markdown
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants