From f9d09411ab7cbe95b4c68f94e43b2b01f4546e83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Maes?= Date: Wed, 9 Aug 2017 09:22:09 +0200 Subject: [PATCH] [IMP] website_rating_project: website published mixin usage 'project.project' should not use 'website.published.mixin', since we don't want to publish a project on the website. All we want is to display the rating of a project, nothing more. So, a flag on project is enought to allow the publication. --- .../controllers/main.py | 4 +-- .../website_rating_project/models/project.py | 26 +++++++++---------- .../views/project_project_view.xml | 12 ++++----- .../views/website_rating_project.xml | 7 ----- 4 files changed, 19 insertions(+), 30 deletions(-) diff --git a/addons/website_rating_project/controllers/main.py b/addons/website_rating_project/controllers/main.py index 5031388108c..4d6b3ecb65e 100644 --- a/addons/website_rating_project/controllers/main.py +++ b/addons/website_rating_project/controllers/main.py @@ -13,7 +13,7 @@ class WebsiteRatingProject(http.Controller): @http.route(['/project/rating/'], type='http', auth="public", website=True) def index(self, **kw): - projects = request.env['project.project'].sudo().search([('rating_status', '!=', 'no'), ('website_published', '=', True)]) + projects = request.env['project.project'].sudo().search([('rating_status', '!=', 'no'), ('portal_show_rating', '=', True)]) values = {'projects': projects} return request.render('website_rating_project.index', values) @@ -23,7 +23,7 @@ class WebsiteRatingProject(http.Controller): project = request.env['project.project'].sudo().browse(project_id) # to avoid giving any access rights on projects to the public user, let's use sudo # and check if the user should be able to view the project (project managers only if it's unpublished or has no rating) - if not ((project.rating_status!='no') and project.website_published) and not user.sudo(user).has_group('project.group_project_manager'): + if not ((project.rating_status!='no') and project.portal_show_rating) and not user.sudo(user).has_group('project.group_project_manager'): raise NotFound() values = { 'project': project, diff --git a/addons/website_rating_project/models/project.py b/addons/website_rating_project/models/project.py index ca0df1796b7..da46693fea4 100644 --- a/addons/website_rating_project/models/project.py +++ b/addons/website_rating_project/models/project.py @@ -1,27 +1,25 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo import api, models +from odoo import api, fields, models class Project(models.Model): _name = "project.project" - _inherit = ['project.project', 'website.published.mixin'] + _inherit = ['project.project'] + + portal_show_rating = fields.Boolean('Rating visible in Website', copy=False, oldname='website_published') @api.multi def action_view_all_rating(self): """ Override this method without calling parent to redirect to rating website project page """ self.ensure_one() - return { - 'type': 'ir.actions.act_url', - 'name': "Redirect to the Website Projcet Rating Page", - 'target': 'self', - 'url': "/project/rating/%s" % (self.id,) - } - - @api.multi - def _compute_website_url(self): - super(Project, self)._compute_website_url() - for project in self: - project.website_url = "/project/rating/%s" % project.id + 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 super(Project, self).action_view_all_rating() diff --git a/addons/website_rating_project/views/project_project_view.xml b/addons/website_rating_project/views/project_project_view.xml index 2596109d93c..8c1e21ef147 100644 --- a/addons/website_rating_project/views/project_project_view.xml +++ b/addons/website_rating_project/views/project_project_view.xml @@ -1,17 +1,15 @@ + + project.project.inherit.form project.project - + - - + + - diff --git a/addons/website_rating_project/views/website_rating_project.xml b/addons/website_rating_project/views/website_rating_project.xml index 30c337ad8df..52e463a040c 100644 --- a/addons/website_rating_project/views/website_rating_project.xml +++ b/addons/website_rating_project/views/website_rating_project.xml @@ -115,13 +115,6 @@

-
- - - - - -