[IMP] project: make project use rating parent mixin
No functionnal changes are done in this commit. Everything stays the same, but use the parent mixin mecanism. Task-1903565
This commit is contained in:
@@ -67,9 +67,10 @@ class ProjectTaskType(models.Model):
|
||||
class Project(models.Model):
|
||||
_name = "project.project"
|
||||
_description = "Project"
|
||||
_inherit = ['portal.mixin', 'mail.alias.mixin', 'mail.thread']
|
||||
_inherit = ['portal.mixin', 'mail.alias.mixin', 'mail.thread', 'rating.parent.mixin']
|
||||
_order = "sequence, name, id"
|
||||
_period_number = 5
|
||||
_rating_satisfaction_days = False # takes all existing ratings
|
||||
|
||||
def get_alias_model_name(self, vals):
|
||||
return vals.get('alias_model', 'project.task')
|
||||
@@ -221,8 +222,6 @@ class Project(models.Model):
|
||||
help="Project in which sub-tasks of the current project will be created. It can be the current project itself.")
|
||||
|
||||
# rating fields
|
||||
percentage_satisfaction_task = fields.Integer(
|
||||
compute='_compute_percentage_satisfaction_task', string="Happy % on Task", help="Satisfaction rate on task.", store=True, default=-1)
|
||||
rating_request_deadline = fields.Datetime(compute='_compute_rating_request_deadline', store=True)
|
||||
rating_status = fields.Selection([('stage', 'Rating when changing stage'), ('periodic', 'Periodical Rating'), ('no','No rating')], 'Customer(s) Ratings', help="How to get customer feedback?\n"
|
||||
"- Rating when changing stage: an email will be sent when a task is pulled in another stage.\n"
|
||||
@@ -250,12 +249,6 @@ class Project(models.Model):
|
||||
project.access_warning = _(
|
||||
"The project cannot be shared with the recipient(s) because the privacy of the project is too restricted. Set the privacy to 'Visible by following customers' in order to make it accessible by the recipient(s).")
|
||||
|
||||
@api.depends('tasks.rating_ids.rating')
|
||||
def _compute_percentage_satisfaction_task(self):
|
||||
for project in self:
|
||||
activity = project.tasks.rating_get_grades()
|
||||
project.percentage_satisfaction_task = activity['great'] * 100 / sum(activity.values()) if sum(activity.values()) else -1
|
||||
|
||||
@api.depends('rating_status', 'rating_status_period')
|
||||
def _compute_rating_request_deadline(self):
|
||||
periods = {'daily': 1, 'weekly': 7, 'bimonthly': 15, 'monthly': 30, 'quarterly': 90, 'yearly': 365}
|
||||
|
||||
@@ -165,8 +165,8 @@ class TestProjectFlow(TestProjectBase):
|
||||
self.assertEqual(first_task.rating_count, 1, "Task should have only one rating associated, since one is not consumed")
|
||||
self.assertEqual(rating_good.parent_res_id, self.project_pigs.id)
|
||||
|
||||
self.assertEqual(self.project_goats.percentage_satisfaction_task, -1)
|
||||
self.assertEqual(self.project_pigs.percentage_satisfaction_task, -1)
|
||||
self.assertEqual(self.project_goats.rating_percentage_satisfaction, -1)
|
||||
self.assertEqual(self.project_pigs.rating_percentage_satisfaction, 0) # There is a rating but not a "great" on, just an "okay".
|
||||
|
||||
# Consuming rating_good
|
||||
first_task.rating_apply(10, rating_good.access_token)
|
||||
@@ -177,8 +177,8 @@ class TestProjectFlow(TestProjectBase):
|
||||
|
||||
self.assertEqual(first_task.rating_count, 2, "Task should have two ratings associated with it")
|
||||
self.assertEqual(rating_good.parent_res_id, self.project_pigs.id)
|
||||
self.assertEqual(self.project_goats.percentage_satisfaction_task, -1)
|
||||
self.assertEqual(self.project_pigs.percentage_satisfaction_task, 50)
|
||||
self.assertEqual(self.project_goats.rating_percentage_satisfaction, -1)
|
||||
self.assertEqual(self.project_pigs.rating_percentage_satisfaction, 50)
|
||||
|
||||
# We change the task from project_pigs to project_goats, ratings should be associated with the new project
|
||||
first_task.project_id = self.project_goats.id
|
||||
@@ -188,5 +188,5 @@ class TestProjectFlow(TestProjectBase):
|
||||
first_task.invalidate_cache()
|
||||
|
||||
self.assertEqual(rating_good.parent_res_id, self.project_goats.id)
|
||||
self.assertEqual(self.project_goats.percentage_satisfaction_task, 50)
|
||||
self.assertEqual(self.project_pigs.percentage_satisfaction_task, -1)
|
||||
self.assertEqual(self.project_goats.rating_percentage_satisfaction, 50)
|
||||
self.assertEqual(self.project_pigs.rating_percentage_satisfaction, -1)
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
</div>
|
||||
</t>
|
||||
<t t-foreach="projects" t-as="project">
|
||||
<div t-if="project.percentage_satisfaction_task != -1" class="col-md-6 col-4 col-lg-4 col-xl-4">
|
||||
<div t-if="project.rating_percentage_satisfaction != -1" class="col-md-6 col-4 col-lg-4 col-xl-4">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="caption">
|
||||
|
||||
@@ -101,10 +101,10 @@
|
||||
name="%(act_project_project_2_project_task_all)d" icon="fa-tasks">
|
||||
<field string="Tasks" name="task_count" widget="statinfo" options="{'label_field': 'label_tasks'}"/>
|
||||
</button>
|
||||
<button name="action_view_all_rating" type="object" attrs="{'invisible': ['|', '|', ('rating_status', '=', 'no'), ('percentage_satisfaction_task', '=', -1)]}" class="oe_stat_button oe_percent" icon="fa-smile-o" groups="project.group_project_rating">
|
||||
<button name="action_view_all_rating" type="object" attrs="{'invisible': ['|', '|', ('rating_status', '=', 'no'), ('rating_percentage_satisfaction', '=', -1)]}" class="oe_stat_button oe_percent" icon="fa-smile-o" groups="project.group_project_rating">
|
||||
<div class="o_field_widget o_stat_info">
|
||||
<span class="o_stat_value">
|
||||
<field name="percentage_satisfaction_task" nolabel="1"/>
|
||||
<field name="rating_percentage_satisfaction" nolabel="1"/>
|
||||
</span>
|
||||
<span class="o_stat_text">
|
||||
% On <field readonly="1" name="label_tasks" options="{'label_field': 'label_tasks'}" />
|
||||
@@ -294,7 +294,7 @@
|
||||
<field name="alias_name"/>
|
||||
<field name="alias_domain"/>
|
||||
<field name="is_favorite"/>
|
||||
<field name="percentage_satisfaction_task"/>
|
||||
<field name="rating_percentage_satisfaction"/>
|
||||
<field name="rating_status"/>
|
||||
<templates>
|
||||
<t t-name="kanban-box">
|
||||
@@ -313,12 +313,12 @@
|
||||
</div>
|
||||
<div t-if="record.rating_status.raw_value != 'no'" class="mt8 text-primary" title="Percentage of happy ratings over the past 30 days. Get rating details from the More menu." groups="project.group_project_rating">
|
||||
<b>
|
||||
<t t-if="record.percentage_satisfaction_task.value == -1">
|
||||
<t t-if="record.rating_percentage_satisfaction.value == -1">
|
||||
<i class="fa fa-smile-o"/> No rating yet
|
||||
</t>
|
||||
<t t-if="record.percentage_satisfaction_task.value != -1">
|
||||
<t t-if="record.rating_percentage_satisfaction.value != -1">
|
||||
<a name="action_view_all_rating" type="object" context="{'search_default_rating_last_30_days':1}">
|
||||
<i class="fa fa-smile-o" role="img" aria-label="Percentage of satisfaction" title="Percentage of satisfaction"/> <t t-esc="record.percentage_satisfaction_task.value"/>%
|
||||
<i class="fa fa-smile-o" role="img" aria-label="Percentage of satisfaction" title="Percentage of satisfaction"/> <t t-esc="record.rating_percentage_satisfaction.value"/>%
|
||||
</a>
|
||||
</t>
|
||||
</b>
|
||||
|
||||
Reference in New Issue
Block a user