[FIX] project, rating: use rating last update to compute satisfaction percentage
The function _compute_parent_rating_percentage_satisfaction used the creation date of the rating to compute the percentage. However when a client give a new rating, it updates the old one. As a result it doesn't give the recent satisfaction percentage, but the satisfaction percentage of recently created tickets. In other words recently angry clients from old projects would not appear. Similarly this method is somewhat reimplemented directly in SQL in the rating route, which happens to be in the project controller. opw 1921486 closes odoo/odoo#30752
This commit is contained in:
@@ -23,10 +23,10 @@ class RatingProject(http.Controller):
|
||||
rating,
|
||||
COUNT(rating) as rating_count,
|
||||
CASE
|
||||
WHEN now()::date - create_date::date BETWEEN 0 AND 6 Then 'days_06'
|
||||
WHEN now()::date - create_date::date BETWEEN 0 AND 15 Then 'days_15'
|
||||
WHEN now()::date - create_date::date BETWEEN 0 AND 30 Then 'days_30'
|
||||
WHEN now()::date - create_date::date BETWEEN 0 AND 90 Then 'days_90'
|
||||
WHEN now()::date - write_date::date BETWEEN 0 AND 6 Then 'days_06'
|
||||
WHEN now()::date - write_date::date BETWEEN 0 AND 15 Then 'days_15'
|
||||
WHEN now()::date - write_date::date BETWEEN 0 AND 30 Then 'days_30'
|
||||
WHEN now()::date - write_date::date BETWEEN 0 AND 90 Then 'days_90'
|
||||
END AS period
|
||||
FROM
|
||||
rating_rating
|
||||
@@ -35,7 +35,7 @@ class RatingProject(http.Controller):
|
||||
AND parent_res_id = %s
|
||||
AND res_model = 'project.task'
|
||||
AND rated_partner_id IS NOT NULL
|
||||
AND create_date >= current_date - interval '90' day
|
||||
AND write_date >= current_date - interval '90' day
|
||||
AND rating IN (1,5,10)
|
||||
GROUP BY
|
||||
rated_partner_id, rating, period
|
||||
|
||||
@@ -360,7 +360,7 @@ class RatingMixin(models.AbstractModel):
|
||||
# build domain and fetch data
|
||||
domain = [('parent_res_model', '=', parent_records._name), ('parent_res_id', 'in', parent_records.ids), ('rating', '>=', 1), ('consumed', '=', True)]
|
||||
if rating_satisfaction_days:
|
||||
domain += [('create_date', '>=', fields.Datetime.to_string(fields.datetime.now() - timedelta(days=rating_satisfaction_days)))]
|
||||
domain += [('write_date', '>=', fields.Datetime.to_string(fields.datetime.now() - timedelta(days=rating_satisfaction_days)))]
|
||||
data = self.env['rating.rating'].read_group(domain, ['parent_res_id', 'rating'], ['parent_res_id', 'rating'], lazy=False)
|
||||
|
||||
# get repartition of grades per parent id
|
||||
|
||||
Reference in New Issue
Block a user