[FIX] portal_rating, rating: Wrong star rating number

Issue

	- Install 'eLearning' module
	- Go to 'Course' page on website
	- Open any course and click on 'Review' tab

	Rating star numbers are 2,4,6,8 & 10.

Cause

	Since this commit https://github.com/odoo/odoo/commit/e4a4ffb974ccde1842e1b2389450718f8576ad5b,
	odoo use a system of 5 stars instead of 10.

opw-2373115

closes odoo/odoo#61158

X-original-commit: e2e1ecd0de467cb97748092554c5abc3b0c9f993
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
Signed-off-by: bon-odoo <nboulif@users.noreply.github.com>
This commit is contained in:
Nasreddin (bon)
2020-11-02 13:12:52 +00:00
parent f7c5fb244f
commit b85680a348
2 changed files with 5 additions and 7 deletions
@@ -117,12 +117,10 @@ PortalChatter.include({
'percent': [],
};
_.each(_.keys(result['rating_stats']['percent']).reverse(), function (rating) {
if (rating % 2 === 0) {
ratingData['percent'].push({
'num': rating,
'percent': utils.round_precision(result['rating_stats']['percent'][rating], 0.01),
});
}
ratingData['percent'].push({
'num': rating,
'percent': utils.round_precision(result['rating_stats']['percent'][rating], 0.01),
});
});
self.set('rating_card_values', ratingData);
});
+1 -1
View File
@@ -266,7 +266,7 @@ class RatingMixin(models.AbstractModel):
result = {
'avg': data['avg'],
'total': data['total'],
'percent': dict.fromkeys(range(1, 11), 0),
'percent': dict.fromkeys(range(1, 6), 0),
}
for rate in data['repartition']:
result['percent'][rate] = (data['repartition'][rate] * 100) / data['total'] if data['total'] > 0 else 0