Files
odoo_source/addons/website_partner/controllers/main.py
T
Thibault Delavallée 014b5c9f7c [MOV] website, http_routing: move (un)slug support to http_routing
Slug and unslug API is now available in http_routing. Indeed there is no
link to any website or any reason to not support slufigied URLs when
website is not installed. A new unslug_url method is added as a tool
coming from an embedded method from website. Doing it allows to have all
slug related methods defined at the same point.

Support of slug and unslug in qweb rendering is also moved directly in
http_routing version of ir_ui_view instead of website inheritance. This
is done in order to keep things coherent.

Some code from website about ModelConverter is also moved. Indeed both
versions of ir_http uses some kind of placeholder to store the uid
when converting urls to python. This commit unifies it by using the
website one directly in base to simplify the override.

This commit also updates all module importing slug. Enterprise modules
will have to be updated, see related commit.
2017-08-08 14:23:58 +02:00

25 lines
1017 B
Python

# -*- coding: utf-8 -*-
from odoo import http
from odoo.addons.http_routing.models.ir_http import unslug
from odoo.http import request
class WebsitePartnerPage(http.Controller):
# Do not use semantic controller due to SUPERUSER_ID
@http.route(['/partners/<partner_id>'], type='http', auth="public", website=True)
def partners_detail(self, partner_id, **post):
_, partner_id = unslug(partner_id)
if partner_id:
partner_sudo = request.env['res.partner'].sudo().browse(partner_id)
is_website_publisher = request.env['res.users'].has_group('website.group_website_publisher')
if partner_sudo.exists() and (partner_sudo.website_published or is_website_publisher):
values = {
'main_object': partner_sudo,
'partner': partner_sudo,
'edit_page': False
}
return request.render("website_partner.partner_page", values)
return request.not_found()