Repository navigation
[18.0][FIX] kpi: history name default evaluated when the server starts - #1229
Open
parabol123654 wants to merge 1 commit into
Open
parabol123654 wants to merge 1 commit into
parabol123654 wants to merge 1 commit into
Conversation
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.
Contributor
|
Hi @max3903, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The default of
nameonkpi.historyisfields.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.