From c06a7cf2de9e2278780e0a210294c4ed3e053d37 Mon Sep 17 00:00:00 2001 From: David Beguin Date: Thu, 5 Mar 2020 09:13:58 +0000 Subject: [PATCH] [FIX] gamification: fix karma tracking demo data Before this commit, when checking the gained karma per month or per week in /profile/users route, the users gained more karma than they actually have. This is due to the way demo data are loaded : karma tracking history is added but when the final karma is set on the user, a new line of karma tracking is created on the DB (via write or create method). But as the transaction with karma tracking demo data is not commited yet, the old value is still 0. That leads to add a new karma tracking line that have old_value = 0 and new_value = user.karma. At the end the users 'gained' as addition the amount of the karma they have. E.g : Mitchell Admin has 2500 karma and his karma tracking history is the following: 0 -> 1000 then 1000 -> 1500 then 1500 -> 2500. In total, Mitchell should have gained 2500 XP: (2500-1500)+(1500-1000)+(1000-0) But, before this commit, as there is an additional 0 to 2500 karma tracking line, Mitchell Admin gain in total : (2500-0)+(2500-1500)+(1500-1000)+(1000-0) = 5000 karma. This commit clean that additional karma tracking line to get a correct karma tracking history. Task ID: 2209743 PR #48042 closes odoo/odoo#48061 X-original-commit: 858f80e2529b17d1857d77f372c378ae235443de Signed-off-by: Thibault Delavallee (tde) --- .../data/gamification_karma_tracking_demo.xml | 37 ++++++++++++++++++- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/addons/gamification/data/gamification_karma_tracking_demo.xml b/addons/gamification/data/gamification_karma_tracking_demo.xml index 01f4d8ac929..1b08eca6336 100644 --- a/addons/gamification/data/gamification_karma_tracking_demo.xml +++ b/addons/gamification/data/gamification_karma_tracking_demo.xml @@ -26,9 +26,22 @@ 2050 + + + 2050 + 2500 + + 2500 + + + @@ -49,15 +62,28 @@ 20 - + 20 25 - + + + + + 25 + 30 + 30 + + + @@ -78,6 +104,13 @@ 2500 + + +