[IMP] project: use the rating average instead of customer satisfaction
Before this commit, we use the `rating_percentage_satisfaction` field to display the customer satisfaction of the project. The problem is this field is not really a rating average. This field returns the percentage of satisfied ratings over the total number of ratings. This commit changes the using of `rating_percentage_satisfaction` field by the `rating_avg` to only use the rating average to really know if globally the customers are happy of a project or not. task-2671848 Closes #81027
This commit is contained in:
@@ -739,11 +739,11 @@ class Project(models.Model):
|
||||
if self.user_has_groups('project.group_project_rating'):
|
||||
buttons.append({
|
||||
'icon': 'smile-o',
|
||||
'text': _('Customer Satisfaction'),
|
||||
'number': '%s %%' % (self.rating_percentage_satisfaction),
|
||||
'text': _('Satisfaction'),
|
||||
'number': f'{self.rating_avg_percentage} %',
|
||||
'action_type': 'object',
|
||||
'action': 'action_view_all_rating',
|
||||
'show': self.rating_active and self.rating_percentage_satisfaction > -1,
|
||||
'show': self.rating_active and self.rating_count > 0,
|
||||
'sequence': 15,
|
||||
})
|
||||
if self.user_has_groups('project.group_project_manager'):
|
||||
|
||||
@@ -319,33 +319,14 @@
|
||||
</span>
|
||||
</div>
|
||||
</button>
|
||||
<button name="action_view_all_rating" type="object" attrs="{'invisible': ['|', ('rating_active', '=', False), ('rating_percentage_satisfaction', '<', 66.6)]}" class="oe_stat_button oe_read_only" icon="fa-smile-o text-success" groups="project.group_project_rating">
|
||||
<field name="rating_avg" invisible="1"/>
|
||||
<button name="action_view_all_rating" type="object" attrs="{'invisible': [('rating_active', '=', False)]}" class="oe_stat_button" groups="project.group_project_rating">
|
||||
<i class="fa fa-fw o_button_icon fa-smile-o text-success" attrs="{'invisible': [('rating_avg', '<', 3.66)]}" title="Satisfied"/>
|
||||
<i class="fa fa-fw o_button_icon fa-meh-o text-warning" attrs="{'invisible': ['|', ('rating_avg', '<', 2.33), ('rating_avg', '>=', 3.66)]}" title="Okay"/>
|
||||
<i class="fa fa-fw o_button_icon fa-frown-o text-danger" attrs="{'invisible': [('rating_avg', '>=', 2.33)]}" title="Dissatisfied"/>
|
||||
<div class="o_field_widget o_stat_info">
|
||||
<span class="o_stat_value">
|
||||
<field name="rating_percentage_satisfaction" nolabel="1"/>
|
||||
%
|
||||
</span>
|
||||
<span class="o_stat_text">
|
||||
Satisfaction
|
||||
</span>
|
||||
</div>
|
||||
</button>
|
||||
<button name="action_view_all_rating" type="object" attrs="{'invisible': ['|', '|', ('rating_active', '=', False), ('rating_percentage_satisfaction', '>=', 66.6), ('rating_percentage_satisfaction', '<', 33.3)]}" class="oe_stat_button oe_read_only" icon="fa-meh-o text-warning" groups="project.group_project_rating">
|
||||
<div class="o_field_widget o_stat_info">
|
||||
<span class="o_stat_value">
|
||||
<field name="rating_percentage_satisfaction" nolabel="1"/>
|
||||
%
|
||||
</span>
|
||||
<span class="o_stat_text">
|
||||
Satisfaction
|
||||
</span>
|
||||
</div>
|
||||
</button>
|
||||
<button name="action_view_all_rating" type="object" attrs="{'invisible': ['|', ('rating_active', '=', False), '|', ('rating_percentage_satisfaction', '>=', 33.3), ('rating_percentage_satisfaction', '<', 0)]}" class="oe_stat_button oe_read_only" icon="fa-frown-o text-danger" groups="project.group_project_rating">
|
||||
<div class="o_field_widget o_stat_info">
|
||||
<span class="o_stat_value">
|
||||
<field name="rating_percentage_satisfaction" nolabel="1"/>
|
||||
%
|
||||
<field name="rating_avg_percentage" nolabel="1" widget="percentage"/>
|
||||
</span>
|
||||
<span class="o_stat_text">
|
||||
Satisfaction
|
||||
@@ -666,7 +647,8 @@
|
||||
<field name="alias_name"/>
|
||||
<field name="alias_domain"/>
|
||||
<field name="is_favorite"/>
|
||||
<field name="rating_percentage_satisfaction"/>
|
||||
<field name="rating_count" />
|
||||
<field name="rating_avg"/>
|
||||
<field name="rating_status"/>
|
||||
<field name="rating_active" />
|
||||
<field name="analytic_account_id"/>
|
||||
@@ -697,12 +679,13 @@
|
||||
<div t-if="record.alias_name.value and record.alias_domain.value" class="text-muted">
|
||||
<span class="fa fa-envelope-o mr-2" aria-label="Domain Alias" title="Domain Alias"></span><t t-esc="record.alias_id.value"/>
|
||||
</div>
|
||||
<div t-if="record.rating_active.raw_value" class="text-muted" groups="project.group_project_rating">
|
||||
<b>
|
||||
<t t-if="record.rating_percentage_satisfaction.value != -1">
|
||||
<i class="fa fa-smile-o" role="img" aria-label="Average satisfaction rate for the last 30 days." title="Average satisfaction rate for the last 30 days."/> <t t-esc="record.rating_percentage_satisfaction.value"/>%
|
||||
</t>
|
||||
<div t-if="record.rating_active.raw_value and record.rating_count.raw_value > 0" class="text-muted" groups="project.group_project_rating">
|
||||
<b class="mr-1">
|
||||
<span style="font-weight:bold;" class="fa mt4 fa-smile-o text-success" t-if="record.rating_avg.raw_value >= 3.66" title="Average Rating: Satisfied" role="img" aria-label="Happy face"/>
|
||||
<span style="font-weight:bold;" class="fa mt4 fa-meh-o text-warning" t-elif="record.rating_avg.raw_value >= 2.33" title="Average Rating: Okay" role="img" aria-label="Neutral face"/>
|
||||
<span style="font-weight:bold;" class="fa mt4 fa-frown-o text-danger" t-else="" title="Average Rating: Dissatisfied" role="img" aria-label="Sad face"/>
|
||||
</b>
|
||||
<field name="rating_avg_percentage" widget="percentage"/>
|
||||
</div>
|
||||
<field name="tag_ids" widget="many2many_tags" options="{'color_field': 'color'}"/>
|
||||
</div>
|
||||
@@ -866,22 +849,13 @@
|
||||
<span id="button_worksheet" invisible="1"/>
|
||||
<!-- Dummy tag used to organize buttons, englobing the 3 buttons modifies the width of the button -->
|
||||
<span id="start_rating_buttons" invisible="1"/>
|
||||
<button name="action_open_ratings" type="object" attrs="{'invisible': ['|', ('rating_count', '=', 0), ('rating_percentage_satisfaction', '<', 66.6)]}" class="oe_stat_button" icon="fa-smile-o text-success" groups="project.group_project_rating">
|
||||
<button name="action_open_ratings" type="object" attrs="{'invisible': [('rating_count', '=', 0)]}" class="oe_stat_button" groups="project.group_project_rating">
|
||||
<i class="fa fa-fw o_button_icon fa-smile-o text-success" attrs="{'invisible': [('rating_avg', '<', 3.66)]}" title="Satisfied"/>
|
||||
<i class="fa fa-fw o_button_icon fa-meh-o text-warning" attrs="{'invisible': ['|', ('rating_avg', '<', 2.33), ('rating_avg', '>=', 3.66)]}" title="Okay"/>
|
||||
<i class="fa fa-fw o_button_icon fa-frown-o text-danger" attrs="{'invisible': [('rating_avg', '>=', 2.33)]}" title="Dissatisfied"/>
|
||||
<div class="o_field_widget o_stat_info">
|
||||
<span class="o_stat_value"><field name="rating_percentage_satisfaction" widget="integer"/>%</span>
|
||||
<span class="o_stat_text">Satisfaction</span>
|
||||
</div>
|
||||
</button>
|
||||
<button name="action_open_ratings" type="object" attrs="{'invisible': ['|', '|', ('rating_count', '=', 0), ('rating_percentage_satisfaction', '>=', 66.6), ('rating_percentage_satisfaction', '<', 33.3)]}" class="oe_stat_button" icon="fa-meh-o text-warning" groups="project.group_project_rating">
|
||||
<div class="o_field_widget o_stat_info">
|
||||
<span class="o_stat_value"><field name="rating_percentage_satisfaction" widget="integer"/>%</span>
|
||||
<span class="o_stat_text">Satisfaction</span>
|
||||
</div>
|
||||
</button>
|
||||
<button name="action_open_ratings" type="object" attrs="{'invisible': ['|', '|', ('rating_count', '=', 0), ('rating_percentage_satisfaction', '>=', 33.3), ('rating_percentage_satisfaction', '<', 0)]}" class="oe_stat_button" icon="fa-frown-o text-danger" groups="project.group_project_rating">
|
||||
<div class="o_field_widget o_stat_info">
|
||||
<span class="o_stat_value"><field name="rating_percentage_satisfaction" widget="integer"/>%</span>
|
||||
<span class="o_stat_text">Satisfaction</span>
|
||||
<span class="o_stat_value"><field name="rating_avg" nolabel="1"/> / 5</span>
|
||||
<span class="o_stat_text">Ratings</span>
|
||||
</div>
|
||||
</button>
|
||||
<!-- Dummy tag used to organize buttons -->
|
||||
|
||||
@@ -35,6 +35,8 @@ class RatingParentMixin(models.AbstractModel):
|
||||
rating_count = fields.Integer(string='# Ratings', compute="_compute_rating_percentage_satisfaction", compute_sudo=True)
|
||||
rating_avg = fields.Float('Average Rating', groups='base.group_user',
|
||||
compute='_compute_rating_percentage_satisfaction', compute_sudo=True, search='_search_rating_avg')
|
||||
rating_avg_percentage = fields.Float('Average Rating (%)', groups='base.group_user',
|
||||
compute='_compute_rating_percentage_satisfaction', compute_sudo=True)
|
||||
rating_last_value = fields.Float('Rating Last Value', groups='base.group_user', related='rating_ids.rating')
|
||||
|
||||
@api.depends('rating_ids.rating', 'rating_ids.consumed')
|
||||
@@ -67,6 +69,7 @@ class RatingParentMixin(models.AbstractModel):
|
||||
record.rating_count = rating_count
|
||||
record.rating_percentage_satisfaction = repartition['great'] * 100 / rating_count if rating_count else -1
|
||||
record.rating_avg = rating_scores_per_parent[record.id] / rating_count if rating_count else 0
|
||||
record.rating_avg_percentage = record.rating_avg / 5
|
||||
|
||||
def _search_rating_avg(self, operator, value):
|
||||
if operator not in OPERATOR_MAPPING:
|
||||
@@ -93,7 +96,7 @@ class RatingMixin(models.AbstractModel):
|
||||
rating_last_feedback = fields.Text('Rating Last Feedback', groups='base.group_user', related='rating_ids.feedback')
|
||||
rating_last_image = fields.Binary('Rating Last Image', groups='base.group_user', related='rating_ids.rating_image')
|
||||
rating_count = fields.Integer('Rating count', compute="_compute_rating_stats", compute_sudo=True)
|
||||
rating_avg = fields.Float("Average Rating",
|
||||
rating_avg = fields.Float("Average Rating", groups='base.group_user',
|
||||
compute='_compute_rating_stats', compute_sudo=True, search='_search_rating_avg')
|
||||
rating_percentage_satisfaction = fields.Float("Rating Satisfaction", compute='_compute_rating_satisfaction', compute_sudo=True)
|
||||
rating_last_text = fields.Selection(string="Rating Text", groups='base.group_user', related="rating_ids.rating_text")
|
||||
|
||||
Reference in New Issue
Block a user