Skip to content

[18.0][FIX] kpi: history name default evaluated when the server starts - #1229

Open
parabol123654 wants to merge 1 commit into
OCA:18.0from
parabol123654:18.0-fix-kpi-history-name
Open

parabol123654 wants to merge 1 commit into
OCA:18.0from
parabol123654:18.0-fix-kpi-history-name

Conversation

@parabol123654

Copy link
Copy Markdown

The default of name on kpi.history is fields.Datetime.now(). Python runs it once, when the module is imported. compute_kpi_value() does not pass a name, so every history line computed by the cron (or by the Compute KPI button) gets the same name: the time the Odoo server (or worker) was started. The name is the first column of the KPI history list.

The fix computes the default when the line is created. It keeps the same format, the datetime as a string.

The new test computes a KPI inside freeze_time("2030-02-15 08:00:00"). Without the fix it fails with '2026-10-31 22:05:47' != '2030-02-15 08:00:00'. 19.0 has the same line; I will forward-port it after merge.

fields.Datetime.now() was called when the module was imported, so every
KPI history line got the time the Odoo server was started as its name.
@OCA-git-bot

Copy link
Copy Markdown
Contributor

Hi @max3903,
some modules you are maintaining are being modified, check this out!

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