Skip to content

[18.0][FIX] subscription_oca: default dates evaluated when the server starts - #1583

Open
parabol123654 wants to merge 1 commit into
OCA:18.0from
parabol123654:18.0-fix-subscription_oca-default-dates
Open

parabol123654 wants to merge 1 commit into
OCA:18.0from
parabol123654:18.0-fix-subscription_oca-default-dates

Conversation

@parabol123654

@parabol123654 parabol123654 commented Oct 31, 2026 •

Copy link
Copy Markdown

The defaults of date_start and recurring_next_date on sale.subscription are date.today(), which Python evaluates once, when the module is imported. A subscription created days after the server (or worker) started gets that old date as its start date and next invoice date.

Steps to reproduce:

  1. Start Odoo on day D.
  2. On day D+3, create a subscription without setting the start date.
  3. Start date and next invoice date are D instead of D+3.

The fix uses fields.Date.context_today as the default, so the date is computed when the record is created (in the user's timezone, like the other date defaults in Odoo).

The new test creates a subscription inside freeze_time("2030-02-15"). Without the fix it fails with '2026-10-31' != '2030-02-15'.

Assisted-by: Claude Opus 5.5

date.today() was called when the module was imported, so new
subscriptions got the date the Odoo server was started as their start
date and next invoice date.

Assisted-by: Claude Opus 5.5
@parabol123654
parabol123654 force-pushed the 18.0-fix-subscription_oca-default-dates branch from 6f92443 to bf62ec0 Compare November 14, 2026 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants