[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) <tde@openerp.com>
This commit is contained in:
Barad Mahendra
2019-11-26 09:32:09 +00:00
committed by Thibault Delavallée
parent 74111d1fbf
commit 525ed1125f
+4
View File
@@ -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)