[ADD] portal: add module for customer portal and sharing features
This module adds required base code for a fully integrated customer portal. It contains the base controller class and base templates. Business addons will add their specific templates and controllers to extend the customer portal. This module contains most code coming from odoo v10 website_portal. Purpose of this module is to allow the display of a customer portal without having a dependency towards website edition and customization capabilities. Some CSS files used in frontend assets are already moved to have a working portal skeleton. A is_public method on users is also added as it will be used in various portal code soon.
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import controllers
|
||||
@@ -0,0 +1,23 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
{
|
||||
'name': 'Customer Portal',
|
||||
'summary': 'Customer Portal',
|
||||
'sequence': '9000',
|
||||
'category': 'Hidden',
|
||||
'description': """
|
||||
This module adds required base code for a fully integrated customer portal.
|
||||
It contains the base controller class and base templates. Business addons
|
||||
will add their specific templates and controllers to extend the customer
|
||||
portal.
|
||||
|
||||
This module contains most code coming from odoo v10 website_portal. Purpose
|
||||
of this module is to allow the display of a customer portal without having
|
||||
a dependency towards website edition and customization capabilities.""",
|
||||
'data': [
|
||||
'views/assets.xml',
|
||||
'views/portal_templates.xml',
|
||||
],
|
||||
'depends': ['http_routing', 'mail'],
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import portal
|
||||
@@ -0,0 +1,17 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo.http import Controller, request, route
|
||||
|
||||
|
||||
class CustomerPortal(Controller):
|
||||
|
||||
def _prepare_portal_layout_values(self):
|
||||
return {
|
||||
'page_name': 'home',
|
||||
}
|
||||
|
||||
@route(['/my', '/my/home'], type='http', auth="user", website=True)
|
||||
def home(self, **kw):
|
||||
values = self._prepare_portal_layout_values()
|
||||
return request.render("portal.portal_layout", values)
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<template id="assets_frontend" inherit_id="web.assets_frontend" name="Portal Assets">
|
||||
<xpath expr="//script[last()]" position="after">
|
||||
<link rel="stylesheet" type="text/less" href="/portal/static/src/less/website.ui.less"/>
|
||||
<link rel="stylesheet" type="text/less" href="/portal/static/src/less/website.wrapwrap.less"/>
|
||||
<link rel="stylesheet" type="text/less" href="/portal/static/src/less/bootstrap.extend.less"/>
|
||||
</xpath>
|
||||
</template>
|
||||
</odoo>
|
||||
@@ -0,0 +1,72 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<template id="frontend_layout" name="Main Frontend Layout">
|
||||
<t t-call="web.layout">
|
||||
<t t-set="head_website">
|
||||
<script type="text/javascript">
|
||||
odoo.session_info = {
|
||||
is_superuser: <t t-esc="json.dumps(request.env.user._is_superuser())"/>,
|
||||
is_system: <t t-esc="json.dumps(request.env.user._is_system())"/>,
|
||||
is_website_user: <t t-esc="json.dumps(request.env.user._is_public())"/>,
|
||||
user_id: <t t-esc="json.dumps(request.env.user.id)" />,
|
||||
is_frontend: true,
|
||||
};
|
||||
</script>
|
||||
|
||||
<t t-call-assets="web.assets_common" t-js="false"/>
|
||||
<t t-call-assets="web.assets_frontend" t-js="false"/>
|
||||
|
||||
<t t-call-assets="web.assets_common" t-css="false"/>
|
||||
<t t-call-assets="web.assets_frontend" t-css="false"/>
|
||||
</t>
|
||||
<t t-set="head" t-value="head_website + (head or '')"/>
|
||||
|
||||
<div id="wrapwrap" t-att-class="pageName or ''">
|
||||
<header>
|
||||
<div class="navbar navbar-default navbar-static-top">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<a href="/" class="navbar-brand logo">
|
||||
<span t-field="res_company.logo" t-options="{'widget': 'image'}" t-att-alt="'Logo of %s' % res_company.name" t-att-title="res_company.name"/>
|
||||
</a>
|
||||
</div>
|
||||
<div class="collapse navbar-collapse navbar-top-collapse">
|
||||
<ul class="nav navbar-nav navbar-right" id="top_menu">
|
||||
<li class="divider" t-ignore="true" t-if="not user_id._is_public()"/>
|
||||
<li class="dropdown" t-ignore="true" t-if="not user_id._is_public()">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
||||
<b>
|
||||
<span t-esc="(len(user_id.name)>25) and (user_id.name[:23]+'...') or user_id.name"/>
|
||||
<span class="caret"></span>
|
||||
</b>
|
||||
</a>
|
||||
<ul class="dropdown-menu js_usermenu" role="menu">
|
||||
<li id="o_logout"><a t-attf-href="/web/session/logout?redirect=/" role="menuitem">Logout</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<main>
|
||||
<t t-raw="0"/>
|
||||
</main>
|
||||
<footer >
|
||||
<div id="footer">
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
</t>
|
||||
</template>
|
||||
|
||||
<template id="portal_layout" name="Portal Layout">
|
||||
<t t-call="portal.frontend_layout">
|
||||
</t>
|
||||
</template>
|
||||
|
||||
<template id="portal_my_home" name="My Portal">
|
||||
<t t-call="portal.portal_layout">
|
||||
</t>
|
||||
</template>
|
||||
</odoo>
|
||||
@@ -10,8 +10,8 @@
|
||||
|
||||
<link rel="stylesheet" type="text/less" href="/web_editor/static/src/less/web_editor.common.less"/>
|
||||
|
||||
<!-- FIXME remove website dependency ..? -->
|
||||
<link href="/website/static/src/less/website.wrapwrap.less" rel="stylesheet" type="text/less"/>
|
||||
<!-- FIXME remove website / portal dependency ..? -->
|
||||
<link href="/portal/static/src/less/website.wrapwrap.less" rel="stylesheet" type="text/less"/>
|
||||
<link href="/website/static/src/less/website.snippets.less" rel="stylesheet" type="text/less"/>
|
||||
|
||||
<!-- TODO: Put in the right report ..? -->
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
'website': 'https://www.odoo.com/page/website-builder',
|
||||
'version': '1.0',
|
||||
'description': "",
|
||||
'depends': ['web', 'web_editor', 'web_planner'],
|
||||
'depends': ['web', 'web_editor', 'web_planner', 'http_routing', 'portal'],
|
||||
'installable': True,
|
||||
'data': [
|
||||
'data/website_data.xml',
|
||||
|
||||
@@ -5,9 +5,9 @@ from . import ir_actions
|
||||
from . import ir_attachment
|
||||
from . import ir_http
|
||||
from . import ir_qweb
|
||||
from . import website
|
||||
from . import ir_ui_view
|
||||
from . import res_company
|
||||
from . import res_partner
|
||||
from . import web_planner
|
||||
from . import website
|
||||
from . import website_config_settings
|
||||
|
||||
@@ -18,12 +18,9 @@
|
||||
|
||||
<template id="assets_frontend" inherit_id="web.assets_frontend" name="Website Assets">
|
||||
<xpath expr="//link[last()]" position="after">
|
||||
<link rel="stylesheet" type="text/less" href="/website/static/src/less/website.ui.less"/>
|
||||
<link rel="stylesheet" type="text/less" href="/website/static/src/less/website.ui.components.less"/>
|
||||
<link rel="stylesheet" type="text/less" href="/website/static/src/less/website.wrapwrap.less"/>
|
||||
<link rel="stylesheet" type="text/less" href="/website/static/src/less/website.snippets.less"/>
|
||||
<link rel="stylesheet" type="text/less" href="/website/static/src/less/website.zoomodoo.less"/>
|
||||
<link rel="stylesheet" type="text/less" href="/website/static/src/less/bootstrap.extend.less"/>
|
||||
</xpath>
|
||||
<xpath expr="//script[last()]" position="after">
|
||||
<script type="text/javascript" src="/website/static/src/js/website.js"></script>
|
||||
|
||||
@@ -561,6 +561,11 @@ class Users(models.Model):
|
||||
# for a few places explicitly clearing the has_group cache
|
||||
has_group.clear_cache = _has_group.clear_cache
|
||||
|
||||
@api.multi
|
||||
def _is_public(self):
|
||||
self.ensure_one()
|
||||
return self.has_group('base.group_public')
|
||||
|
||||
@api.multi
|
||||
def _is_system(self):
|
||||
self.ensure_one()
|
||||
|
||||
Reference in New Issue
Block a user