From 7702bbf42cbea21eb4217e16f7a432b0dd9bc9aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Maes?= Date: Mon, 8 May 2017 13:41:54 +0200 Subject: [PATCH] [IMP] rating_project: simplify action to see project rating Rating improvements : - use parent res_model/res_id in action domain for performance issue - satisfaction on project kanban card redirect to rating kanban with default filter - UX improvements - Clean method generatign action to rating kanban, according to the project settings (use tasks and/or issues). --- addons/rating_project/models/project.py | 22 ++++++------- addons/rating_project/views/project_view.xml | 31 +++++++++++++++---- .../models/project_issue.py | 24 ++------------ .../views/project_issue_view.xml | 19 ++++++++++-- 4 files changed, 53 insertions(+), 43 deletions(-) diff --git a/addons/rating_project/models/project.py b/addons/rating_project/models/project.py index b7a5a47210e..915c97848ec 100644 --- a/addons/rating_project/models/project.py +++ b/addons/rating_project/models/project.py @@ -3,8 +3,8 @@ from datetime import timedelta -from odoo import api, fields, models from odoo.tools import pycompat +from odoo import api, fields, models, _ from odoo.tools.safe_eval import safe_eval @@ -108,17 +108,13 @@ class Project(models.Model): for project in self: project.rating_request_deadline = fields.datetime.now() + timedelta(days=periods.get(project.rating_status_period, 0)) - @api.multi - def action_view_task_rating(self): - """ return the action to see all the rating about the tasks of the project """ - action = self.env['ir.actions.act_window'].for_xml_id('rating_project', 'rating_rating_action_view_project_rating') - action_domain = safe_eval(action['domain']) if action['domain'] else [] - domain = ['&', ('res_id', 'in', self.tasks.ids), ('res_model', '=', 'project.task')] - if action_domain: - domain = ['&'] + domain + action_domain - return dict(action, domain=domain) - @api.multi def action_view_all_rating(self): - """ return the action to see all the rating about the all sort of activity of the project (tasks, issues, ...) """ - return self.action_view_task_rating() + """ 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('rating_project', 'rating_rating_action_view_project_rating') + action['name'] = _('Ratings of %s') % (self.name,) + action_context = safe_eval(action['context']) if action['context'] else {} + action_context.update(self._context) + if self.use_tasks: + action_context['search_default_rating_tasks'] = 1 + return dict(action, context=action_context) diff --git a/addons/rating_project/views/project_view.xml b/addons/rating_project/views/project_view.xml index b0d4c9e5b10..4ef55bb2ab5 100644 --- a/addons/rating_project/views/project_view.xml +++ b/addons/rating_project/views/project_view.xml @@ -16,6 +16,10 @@ + + + + @@ -23,7 +27,7 @@ Rating rating.rating kanban,tree,graph,pivot,form - [('consumed','=',True)] + [('consumed','=',True), ('parent_res_model','=','project.project'), ('parent_res_id','=',active_id)]

@@ -32,6 +36,19 @@ + + Ratings for tasks + rating.rating + kanban,tree,graph,pivot,form + [('consumed','=',True), ('parent_res_model','=','project.project'), ('parent_res_id','=',active_id), ('res_model','=','project.task')] + + +

+ There is no rating for tasks of this project at the moment. +

+
+ + Customer Ratings from task rating.rating @@ -99,10 +116,10 @@
- @@ -134,12 +151,13 @@
- - No rating yet + No rating yet - % + + % +
@@ -179,6 +197,7 @@ Customer ratings on tasks/issues. If you have no rating, change your project Settings to activate it.

+ {} + + Ratings for issues + rating.rating + kanban,tree,graph,pivot,form + [('consumed','=',True), ('parent_res_model','=','project.project'), ('parent_res_id','=',active_id), ('res_model','=','project.issue')] + + +

+ There is no rating for issues of this project at the moment. +

+
+
+ Customer Ratings rating.rating @@ -21,7 +34,7 @@ - + @@ -79,10 +92,10 @@
-