Skip to content

[17.0][FIX] kpi: history name default evaluated when the server starts - #1242

Open
prashantpag26 wants to merge 1 commit into
OCA:17.0from
prashantpag26:17.0-fix-kpi-history-name-default
Open

prashantpag26 wants to merge 1 commit into
OCA:17.0from
prashantpag26:17.0-fix-kpi-history-name-default

Conversation

@prashantpag26

Copy link
Copy Markdown

Backport of #1229 (18.0).

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 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") and checks the name of the history line.

This was not run in a live Odoo instance.

The default of name on kpi.history was fields.Datetime.now(), which is
evaluated once when the module is imported, so every history line got
the time the server was started. Compute it when the line is created.
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