diff options
| author | Benjamin Frantzen (bfr) <bfr@odoo.com> | 2019-12-18 13:45:38 +0000 |
|---|---|---|
| committer | Yannick Tivisse <yti@odoo.com> | 2020-05-08 12:17:20 +0000 |
| commit | e4a4ffb974ccde1842e1b2389450718f8576ad5b (patch) | |
| tree | 6159873058286c65a3a3bfb5a48f2ef5ffbf7565 /addons/project/models | |
| parent | f427a38c4e0dcd63d086706ad66a3e5570fbf0aa (diff) | |
[IMP] customer ratings flow improvements
- Rename the 'Use Rating on Project' feature into 'Customer Ratings'
- Rename the 'Set Email Template to Stages' link to 'Set a Rating Email Template on Stages'
- Add an optional list view for the Stages menu
- display warning if the rating_template_id field is set and if one of the selected project_ids doesn't have the rating_status field set to true
- Project form view revamp
- rename the '% on tasks' stat button into 'Customer Satisfaction'
- Remove the 'no option' for the rating frequency field because it is required
- project form : Add a 'Go to Website' stat button
- Project dashboard: remove the 'Customer Ratings' menu item in more
- Ratings page: the 'Last 30 days' filter include ratings from today
- remove the Appointment / Helpdesk Customer Satisfaction / Live Support menu items
TASK ID : 1251
Diffstat (limited to 'addons/project/models')
| -rw-r--r-- | addons/project/models/project.py | 50 | ||||
| -rw-r--r-- | addons/project/models/res_config_settings.py | 16 |
2 files changed, 26 insertions, 40 deletions
diff --git a/addons/project/models/project.py b/addons/project/models/project.py index 8accaa81de7..cc90d132df1 100644 --- a/addons/project/models/project.py +++ b/addons/project/models/project.py @@ -51,6 +51,7 @@ class ProjectTaskType(models.Model): " * A good feedback from the customer will update the kanban state to 'ready for the new stage' (green bullet).\n" " * A medium or a bad feedback will set the kanban state to 'blocked' (red bullet).\n") is_closed = fields.Boolean('Closing Stage', help="Tasks in this stage are considered as closed.") + disabled_rating_warning = fields.Text(compute='_compute_disabled_rating_warning') def unlink_wizard(self, stage_view=False): self = self.with_context(active_test=False) @@ -82,6 +83,15 @@ class ProjectTaskType(models.Model): self.env['project.task'].search([('stage_id', 'in', self.ids)]).write({'active': False}) return super(ProjectTaskType, self).write(vals) + @api.depends('project_ids', 'project_ids.rating_active') + def _compute_disabled_rating_warning(self): + for stage in self: + disabled_projects = stage.project_ids.filtered(lambda p: not p.rating_active) + if disabled_projects: + stage.disabled_rating_warning = '\n'.join('- %s' % p.name for p in disabled_projects) + else: + stage.disabled_rating_warning = False + class Project(models.Model): _name = "project.project" @@ -172,11 +182,6 @@ class Project(models.Model): def _get_default_favorite_user_ids(self): return [(6, 0, [self.env.uid])] - def _get_default_rating_status(self): - if self.user_has_groups('project.group_project_rating'): - return 'stage' - return 'no' - name = fields.Char("Name", index=True, required=True, tracking=True) active = fields.Boolean(default=True, help="If the active field is set to False, it will allow you to hide the project without removing it.") @@ -238,20 +243,22 @@ class Project(models.Model): # rating fields 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')], string='Customer Ratings', default=_get_default_rating_status, required=True, + rating_active = fields.Boolean('Customer Ratings', default=True) + rating_status = fields.Selection( + [('stage', 'Rating when changing stage'), + ('periodic', 'Periodical Rating') + ], 'Customer Ratings Status', default="stage", required=True, 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" - "- Periodical Rating: email will be sent periodically.\n\n" - "Don't forget to set up the mail templates on the stages for which you want to get the customer's feedbacks.") + "- Rating when changing stage: an email will be sent when a task is pulled in another stage.\n" + "- Periodical Rating: email will be sent periodically.\n\n" + "Don't forget to set up the mail templates on the stages for which you want to get the customer's feedbacks.") rating_status_period = fields.Selection([ - ('daily', 'Daily'), ('weekly', 'Weekly'), ('bimonthly', 'Twice a Month'), - ('monthly', 'Once a Month'), ('quarterly', 'Quarterly'), ('yearly', 'Yearly') - ], 'Rating Frequency') - - portal_show_rating = fields.Boolean('Rating visible publicly', copy=False) + ('daily', 'Daily'), + ('weekly', 'Weekly'), + ('bimonthly', 'Twice a Month'), + ('monthly', 'Once a Month'), + ('quarterly', 'Quarterly'), + ('yearly', 'Yearly')], 'Rating Frequency', required=True, default='monthly') _sql_constraints = [ ('project_date_greater', 'check(date >= date_start)', 'Error! project start-date must be lower than project end-date.') @@ -452,14 +459,7 @@ class Project(models.Model): return action def action_view_all_rating(self): - """ return the action to see all the rating of the project, and activate default filters """ - if self.portal_show_rating: - return { - 'type': 'ir.actions.act_url', - 'name': "Redirect to the Website Projcet Rating Page", - 'target': 'self', - 'url': "/project/rating/%s" % (self.id,) - } + """ return the action to see all the rating of the project and activate default filters""" action = self.env['ir.actions.act_window'].for_xml_id('project', 'rating_rating_action_view_project_rating') action['name'] = _('Ratings of %s') % (self.name,) action_context = ast.literal_eval(action['context']) if action['context'] else {} diff --git a/addons/project/models/res_config_settings.py b/addons/project/models/res_config_settings.py index 439e09d7705..e63c53edc59 100644 --- a/addons/project/models/res_config_settings.py +++ b/addons/project/models/res_config_settings.py @@ -10,18 +10,4 @@ class ResConfigSettings(models.TransientModel): module_project_forecast = fields.Boolean(string="Planning") module_hr_timesheet = fields.Boolean(string="Task Logs") group_subtask_project = fields.Boolean("Sub-tasks", implied_group="project.group_subtask_project") - group_project_rating = fields.Boolean("Use Rating on Project", implied_group='project.group_project_rating') - - def _get_subtasks_projects_domain(self): - return [] - - def execute(self): - res = super(ResConfigSettings, self).execute() - if self.group_project_rating: - # Change the rating status on existing projects from 'no' to 'stage' - self.env['project.project'].search([('rating_status', '=', 'no')]).write({ - 'rating_status': 'stage'}) - if self.group_subtask_project: - domain = self._get_subtasks_projects_domain() - self.env['project.project'].search(domain).write({'allow_subtasks': True}) - return res + group_project_rating = fields.Boolean("Customer Ratings", implied_group='project.group_project_rating') |
