From 525ed1125fbf895463abcefb94c194029741c698 Mon Sep 17 00:00:00 2001 From: Barad Mahendra Date: Tue, 26 Nov 2019 06:16:00 +0000 Subject: [PATCH] [FIX] digest: force recompute of all kpis each time-based run Before this commit, the computation of kpi for last week, last 30 days and previous period comparison was wrong due to cache. Indeed as first value was in cache, other values were taken directly from cache itself instead of recomputing each value based on start_date and end_date of the computation timeframe. As digest fields are computed fields used a bit off-side, let us manually invalidate the cache before computing a kpi so that it correctly computes the timeframe values. Task ID 1883428 closes odoo/odoo#40861 Closes: #40834 X-original-commit: 2966ee59cabc2bbae91e4ac4701fc393bc3770ae Signed-off-by: Thibault Delavallee (tde) --- addons/digest/models/digest.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/addons/digest/models/digest.py b/addons/digest/models/digest.py index c8f49d8967f..432625588a8 100644 --- a/addons/digest/models/digest.py +++ b/addons/digest/models/digest.py @@ -113,7 +113,11 @@ class Digest(models.Model): try: compute_value = digest[field_name + '_value'] + # Context start and end date is different each time so invalidate to recompute. + digest.invalidate_cache([field_name + '_value']) previous_value = previous_digest[field_name + '_value'] + # Context start and end date is different each time so invalidate to recompute. + previous_digest.invalidate_cache([field_name + '_value']) except AccessError: # no access rights -> just skip that digest details from that user's digest email continue margin = self._get_margin_value(compute_value, previous_value)