flectra/addons/website_partner/controllers/main.py
Siddharth Bhalgami e088762a21 [IMP] Improve Multi-Website Functionalities:-
- Affected Modules:
    website_sale, website_blog, website_partner, website_crm_partner_assign,
    website_customer, website_slides, website_links, website_membership,
    website_hr, website_hr_recruitment, website_payment, website_sale_delivery,
    website_forum, website_event

- Remove unnecessary model `website.product.pricelist` from website_sale,
  All its mechanism already transferd to existing model `product.pricelist`

- Change in `product.pricelist` model, make website_id(o2m) to website_ids(m2m),
  As user can choose that same pricelist can be used in multiple websites

- Added `default_website` as default values in `website_ids(m2m)` & `website_id(m2o)` field in
  almost all affected modules (mentioned above!!)

- To use/publish things(like... product, pricelist, blog, forum, events, etc...) in website,
  User have to set `website_published` mechanism `on` (if it's available for that model/object),
  Also have to set/assign different websites in `website_ids` field as per needs
2018-02-12 18:44:52 +05:30

28 lines
1.2 KiB
Python

# -*- coding: utf-8 -*-
from flectra import http
from flectra.addons.http_routing.models.ir_http import unslug
from flectra.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)
if not request.env.user.has_group('website.group_website_publisher') \
and request.website.id not in partner_sudo.website_ids.ids:
return request.render('website.404')
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()