[FIX] fix and improvements on rating system

This commit is contained in:
Fabien Pinckaers
2015-02-15 22:27:54 +01:00
parent 3f5aef24b9
commit 75203e18c1
5 changed files with 7 additions and 16 deletions
+1 -8
View File
@@ -48,18 +48,11 @@ class Project(models.Model):
activity = self.tasks.rating_get_grades()
self.percentage_satisfaction_task = activity['great'] * 100 / sum(activity.values()) if sum(activity.values()) else -1
@api.one
@api.depends('use_tasks')
def _display_happy_customer(self):
self.is_visible_happy_customer = self.use_tasks
percentage_satisfaction_task = fields.Integer(
compute='_compute_percentage_satisfaction_task', string='% Happy', store=True, default=-1)
percentage_satisfaction_project = fields.Integer(
compute="_compute_percentage_satisfaction_project", string="% Happy", store=True, default=-1)
is_visible_happy_customer = fields.Boolean(
compute="_display_happy_customer", string="Is Visible", store=True, default=True)
is_visible_happy_customer = fields.Boolean(string="Customer Satisfaction", default=False)
@api.multi
+4 -1
View File
@@ -10,13 +10,16 @@
<field name="arch" type="xml">
<xpath expr="//div[@name='buttons']" position="inside">
<button name="action_view_task_rating"
attrs="{'invisible': ['|', ('use_tasks','=', False), ('percentage_satisfaction_task','=', -1)]}"
attrs="{'invisible': ['|', ('use_issues','=', False), ('is_visible_happy_customer','=', False)]}"
class="oe_stat_button oe_percent"
type="object"
icon="fa-smile-o">
<field string="On tasks" name="percentage_satisfaction_task" widget="statinfo"/>
</button>
</xpath>
<xpath expr="//field[@name='privacy_visibility']" position="after">
<field name="is_visible_happy_customer"/>
</xpath>
</field>
</record>
@@ -65,11 +65,6 @@ class Project(models.Model):
activity = project_issue.rating_get_grades()
self.percentage_satisfaction_issue = activity['great'] * 100 / sum(activity.values()) if sum(activity.values()) else -1
@api.one
@api.depends('use_tasks', 'use_issues')
def _display_happy_customer(self):
self.is_visible_happy_customer = self.use_tasks if self.use_tasks else self.use_issues
percentage_satisfaction_issue = fields.Integer(compute='_compute_percentage_satisfaction_issue', string='% Happy', store=True, default=-1)
@api.multi
@@ -10,7 +10,7 @@
<field name="arch" type="xml">
<xpath expr="//div[@name='buttons']" position="inside">
<button name="action_view_issue_rating"
attrs="{'invisible': ['|', ('use_issues','=', False), ('percentage_satisfaction_issue','=', -1)]}"
attrs="{'invisible': ['|', ('use_issues','=', False), ('is_visible_happy_customer','=', False)]}"
class="oe_stat_button oe_percent"
type="object"
icon="fa-smile-o">
@@ -13,7 +13,7 @@ class WebsiteRatingProject(http.Controller):
values = {'projects' : projects}
return request.website.render('website_rating_project_issue.index', values)
@http.route(['/project/rating/<model("project.project"):project>'], type='http', auth="public", website=True)
@http.route(['''/project/rating/<model("project.project", "[('is_visible_happy_customer','=',1)]"):project>'''], type='http', auth="public", website=True)
def page(self, project=None, **kw):
# create domain for rating
domain = [('res_model', '=', 'project.task')]