[MOV]hide_portal_module_by_user: from elabore-addons to ux-tools
This commit is contained in:
2
hide_portal_module_by_user/.gitignore
vendored
Normal file
2
hide_portal_module_by_user/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
*.*~
|
||||||
|
*pyc
|
||||||
64
hide_portal_module_by_user/README.rst
Normal file
64
hide_portal_module_by_user/README.rst
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
==========================
|
||||||
|
Hide Portal Module By User
|
||||||
|
==========================
|
||||||
|
|
||||||
|
Show / Hide Specific Portal Docs on res.users
|
||||||
|
|
||||||
|
|
||||||
|
IMPORTANT
|
||||||
|
=============
|
||||||
|
!! IMPORTANT !!
|
||||||
|
|
||||||
|
This module doesnt modify the access rights of the users, it only hides the documents.
|
||||||
|
|
||||||
|
This Module will Allow to enter a specific document via URL even when the user does not have the group assigned to it.
|
||||||
|
|
||||||
|
|
||||||
|
REVIEW YOUR USE CASES
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
if you dont have the group assigned to it.
|
||||||
|
|
||||||
|
- you can access to the document via URL: /my/orders/6?access_token=0f13c269-0f10-46dc-81f8-4db9682f2267
|
||||||
|
- but not to my/orders
|
||||||
|
|
||||||
|
|
||||||
|
PLEASE MAKE A PR IF YOU I MISSED TO WHITELIST A ROUTE URL
|
||||||
|
|
||||||
|
Usage
|
||||||
|
=====
|
||||||
|
|
||||||
|
To use this module, you need to:
|
||||||
|
|
||||||
|
#. Install and Configure the Groups and Users
|
||||||
|
|
||||||
|
.. image:: static/description/img.png
|
||||||
|
:alt: hide_portal_module_by_user 1
|
||||||
|
:width: 50%
|
||||||
|
|
||||||
|
.. image:: static/description/img_1.png
|
||||||
|
:alt: hide_portal_module_by_user 2
|
||||||
|
:width: 50%
|
||||||
|
|
||||||
|
.. image:: static/description/img_2.png
|
||||||
|
:alt: hide_portal_module_by_user 3
|
||||||
|
:width: 50%
|
||||||
|
|
||||||
|
.. image:: static/description/img_3.png
|
||||||
|
:alt: hide_portal_module_by_user 24
|
||||||
|
:width: 50%
|
||||||
|
|
||||||
|
.. image:: static/description/img_4.png
|
||||||
|
:alt: hide_portal_module_by_user 24
|
||||||
|
:width: 50%
|
||||||
|
|
||||||
|
How it Works
|
||||||
|
=====
|
||||||
|
- At Installation, the module will search for all the views that inherits portal.portal_my_home and create a group based on the URL that its linked to in the anchor tag.
|
||||||
|
- Post Installation, the module will detect if a new view is created inheriting the portal home and create the group.
|
||||||
|
- We Add a validation at view level to hide the group and a validation when trying to list the portal documents.
|
||||||
|
|
||||||
|
|
||||||
|
Changelog
|
||||||
|
=========
|
||||||
3
hide_portal_module_by_user/__init__.py
Normal file
3
hide_portal_module_by_user/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
from . import models
|
||||||
|
from . import controllers
|
||||||
|
from .hooks import post_init_hook
|
||||||
22
hide_portal_module_by_user/__manifest__.py
Normal file
22
hide_portal_module_by_user/__manifest__.py
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
# Copyright 2026 Munin
|
||||||
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
{
|
||||||
|
'name': 'Hide Portal Module By User',
|
||||||
|
'description': """
|
||||||
|
Show / Hide Specific Portal Docs on res.users""",
|
||||||
|
'version': '16.0.1.0.0',
|
||||||
|
'license': 'AGPL-3',
|
||||||
|
'author': 'Munin',
|
||||||
|
'website': 'https://github.com/AxeldelosReyes/odoo_web_modules',
|
||||||
|
'depends': [
|
||||||
|
'base', 'portal','base_portal_type'
|
||||||
|
],
|
||||||
|
'data': [
|
||||||
|
'views/portal_home.xml',
|
||||||
|
'views/res_groups.xml',
|
||||||
|
],
|
||||||
|
'demo': [
|
||||||
|
],
|
||||||
|
'post_init_hook': 'post_init_hook',
|
||||||
|
}
|
||||||
1
hide_portal_module_by_user/controllers/__init__.py
Normal file
1
hide_portal_module_by_user/controllers/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from . import main
|
||||||
19
hide_portal_module_by_user/controllers/main.py
Normal file
19
hide_portal_module_by_user/controllers/main.py
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
# Copyright 2026 Munin
|
||||||
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
from odoo.http import request
|
||||||
|
from odoo.addons.portal.controllers.portal import CustomerPortal
|
||||||
|
from werkzeug.exceptions import NotFound
|
||||||
|
|
||||||
|
WHITELISTED_ROUTES = ['/my/home', '/my', '/my/account', '/my/security', '/my/payment_method']
|
||||||
|
|
||||||
|
|
||||||
|
class CustomerPortalPolicy(CustomerPortal):
|
||||||
|
def _prepare_portal_layout_values(self):
|
||||||
|
vals = super()._prepare_portal_layout_values()
|
||||||
|
current_path = request.httprequest.path
|
||||||
|
if request.env.user.validate_portal_url(current_path) or current_path in WHITELISTED_ROUTES:
|
||||||
|
return vals
|
||||||
|
if '/my/' not in current_path:
|
||||||
|
return vals
|
||||||
|
raise NotFound()
|
||||||
17
hide_portal_module_by_user/hooks.py
Normal file
17
hide_portal_module_by_user/hooks.py
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
from odoo import api, SUPERUSER_ID
|
||||||
|
|
||||||
|
|
||||||
|
def post_init_hook(cr, registry):
|
||||||
|
"""Loaded after installing the module.
|
||||||
|
This module's DB modifications will be available.
|
||||||
|
:param odoo.sql_db.Cursor cr:
|
||||||
|
Database cursor.
|
||||||
|
:param odoo.modules.registry.RegistryManager registry:
|
||||||
|
Database registry, using v7 api.
|
||||||
|
"""
|
||||||
|
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||||
|
portal_views = env['ir.ui.view'].search([('inherit_id.xml_id', '=', 'portal.portal_my_home')])
|
||||||
|
if portal_views:
|
||||||
|
for p in portal_views:
|
||||||
|
p.create_group_from_view()
|
||||||
|
return True
|
||||||
2
hide_portal_module_by_user/models/__init__.py
Normal file
2
hide_portal_module_by_user/models/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
from . import res_users
|
||||||
|
from . import ir_ui_view
|
||||||
68
hide_portal_module_by_user/models/ir_ui_view.py
Normal file
68
hide_portal_module_by_user/models/ir_ui_view.py
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
# Copyright 2026 Munin
|
||||||
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||||
|
from lxml import etree
|
||||||
|
from odoo import _, api, fields, models
|
||||||
|
|
||||||
|
|
||||||
|
class ResGroups(models.Model):
|
||||||
|
_inherit = "res.groups"
|
||||||
|
|
||||||
|
portal_url = fields.Char(string='Portal URL', index=True)
|
||||||
|
|
||||||
|
|
||||||
|
class IrUiView(models.Model):
|
||||||
|
_inherit = "ir.ui.view"
|
||||||
|
|
||||||
|
custom_portal_group = fields.Boolean(string='Custom Portal Group', default=False)
|
||||||
|
portal_group = fields.Many2one('res.groups', string='Portal Group')
|
||||||
|
|
||||||
|
@api.model_create_multi
|
||||||
|
def create(self, vals_list):
|
||||||
|
res = super(IrUiView, self).create(vals_list)
|
||||||
|
for view in res:
|
||||||
|
if view.inherit_id.xml_id == 'portal.portal_my_home':
|
||||||
|
view.create_group_from_view()
|
||||||
|
return res
|
||||||
|
|
||||||
|
def create_group_from_view(self):
|
||||||
|
self.ensure_one()
|
||||||
|
|
||||||
|
def _generate_name(name):
|
||||||
|
return f"show_portal_{name}".lower().replace(' ', '_')
|
||||||
|
|
||||||
|
view_xml = etree.fromstring(self.arch)
|
||||||
|
groups_from_view = {}
|
||||||
|
for option in view_xml.xpath("//t[@t-call='portal.portal_docs_entry']"):
|
||||||
|
has_title = option.find("t[@t-set='title']")
|
||||||
|
if has_title is not None:
|
||||||
|
title = has_title.text
|
||||||
|
else:
|
||||||
|
title = self.name
|
||||||
|
|
||||||
|
k = _generate_name(title)
|
||||||
|
target_url = option.find("t[@t-set='url']")
|
||||||
|
if target_url is not None:
|
||||||
|
target_url = target_url.get('t-value').replace("'", '')
|
||||||
|
else:
|
||||||
|
raise ValueError(_("No target url found"))
|
||||||
|
groups_from_view[k] = target_url
|
||||||
|
|
||||||
|
search_groups = self.env['res.groups'].sudo().search([('portal_url', 'in', list(groups_from_view.values()))])
|
||||||
|
category_portal_type = self.env.ref('base_portal_type.category_portal_type')
|
||||||
|
base_user_group = self.env.ref('base.group_user')
|
||||||
|
|
||||||
|
for group in groups_from_view.keys():
|
||||||
|
portal_group = search_groups.filtered(lambda g: g.portal_url == groups_from_view[group])
|
||||||
|
if not portal_group:
|
||||||
|
portal_group = self.env['res.groups'].sudo().create(
|
||||||
|
{
|
||||||
|
'name': group,
|
||||||
|
'portal_url': groups_from_view[group],
|
||||||
|
'category_id': category_portal_type.id,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
if base_user_group and portal_group:
|
||||||
|
implied_ids = base_user_group.sudo().mapped('implied_ids.id')
|
||||||
|
if portal_group.id not in implied_ids:
|
||||||
|
base_user_group.sudo().write({'implied_ids': [(4, portal_group.id)]})
|
||||||
|
return True
|
||||||
16
hide_portal_module_by_user/models/res_users.py
Normal file
16
hide_portal_module_by_user/models/res_users.py
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
# Copyright 2026 Munin
|
||||||
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
from odoo import fields, models
|
||||||
|
|
||||||
|
|
||||||
|
class ResUsers(models.Model):
|
||||||
|
_inherit = "res.users"
|
||||||
|
|
||||||
|
portal_url = fields.Char(string='Portal URL')
|
||||||
|
|
||||||
|
def validate_portal_url(self, url):
|
||||||
|
group = self.sudo().env['res.groups'].search([('portal_url', '=', url)])
|
||||||
|
if self.env.user in group.users:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
BIN
hide_portal_module_by_user/static/description/icon.png
Normal file
BIN
hide_portal_module_by_user/static/description/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.0 KiB |
BIN
hide_portal_module_by_user/static/description/img.png
Normal file
BIN
hide_portal_module_by_user/static/description/img.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 73 KiB |
BIN
hide_portal_module_by_user/static/description/img_1.png
Normal file
BIN
hide_portal_module_by_user/static/description/img_1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 93 KiB |
BIN
hide_portal_module_by_user/static/description/img_2.png
Normal file
BIN
hide_portal_module_by_user/static/description/img_2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 51 KiB |
BIN
hide_portal_module_by_user/static/description/img_3.png
Normal file
BIN
hide_portal_module_by_user/static/description/img_3.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 94 KiB |
BIN
hide_portal_module_by_user/static/description/img_4.png
Normal file
BIN
hide_portal_module_by_user/static/description/img_4.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 71 KiB |
406
hide_portal_module_by_user/static/description/index.html
Normal file
406
hide_portal_module_by_user/static/description/index.html
Normal file
@@ -0,0 +1,406 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||||
|
<meta name="generator" content="Docutils 0.20.1: https://docutils.sourceforge.io/" />
|
||||||
|
<title>Hide Portal Module By User</title>
|
||||||
|
<style type="text/css">
|
||||||
|
|
||||||
|
/*
|
||||||
|
:Author: David Goodger (goodger@python.org)
|
||||||
|
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
|
||||||
|
:Copyright: This stylesheet has been placed in the public domain.
|
||||||
|
|
||||||
|
Default cascading style sheet for the HTML output of Docutils.
|
||||||
|
|
||||||
|
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
|
||||||
|
customize this style sheet.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* used to remove borders from tables and images */
|
||||||
|
.borderless, table.borderless td, table.borderless th {
|
||||||
|
border: 0 }
|
||||||
|
|
||||||
|
table.borderless td, table.borderless th {
|
||||||
|
/* Override padding for "table.docutils td" with "! important".
|
||||||
|
The right padding separates the table cells. */
|
||||||
|
padding: 0 0.5em 0 0 ! important }
|
||||||
|
|
||||||
|
.first {
|
||||||
|
/* Override more specific margin styles with "! important". */
|
||||||
|
margin-top: 0 ! important }
|
||||||
|
|
||||||
|
.last, .with-subtitle {
|
||||||
|
margin-bottom: 0 ! important }
|
||||||
|
|
||||||
|
.hidden {
|
||||||
|
display: none }
|
||||||
|
|
||||||
|
.subscript {
|
||||||
|
vertical-align: sub;
|
||||||
|
font-size: smaller }
|
||||||
|
|
||||||
|
.superscript {
|
||||||
|
vertical-align: super;
|
||||||
|
font-size: smaller }
|
||||||
|
|
||||||
|
a.toc-backref {
|
||||||
|
text-decoration: none ;
|
||||||
|
color: black }
|
||||||
|
|
||||||
|
blockquote.epigraph {
|
||||||
|
margin: 2em 5em ; }
|
||||||
|
|
||||||
|
dl.docutils dd {
|
||||||
|
margin-bottom: 0.5em }
|
||||||
|
|
||||||
|
object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Uncomment (and remove this text!) to get bold-faced definition list terms
|
||||||
|
dl.docutils dt {
|
||||||
|
font-weight: bold }
|
||||||
|
*/
|
||||||
|
|
||||||
|
div.abstract {
|
||||||
|
margin: 2em 5em }
|
||||||
|
|
||||||
|
div.abstract p.topic-title {
|
||||||
|
font-weight: bold ;
|
||||||
|
text-align: center }
|
||||||
|
|
||||||
|
div.admonition, div.attention, div.caution, div.danger, div.error,
|
||||||
|
div.hint, div.important, div.note, div.tip, div.warning {
|
||||||
|
margin: 2em ;
|
||||||
|
border: medium outset ;
|
||||||
|
padding: 1em }
|
||||||
|
|
||||||
|
div.admonition p.admonition-title, div.hint p.admonition-title,
|
||||||
|
div.important p.admonition-title, div.note p.admonition-title,
|
||||||
|
div.tip p.admonition-title {
|
||||||
|
font-weight: bold ;
|
||||||
|
font-family: sans-serif }
|
||||||
|
|
||||||
|
div.attention p.admonition-title, div.caution p.admonition-title,
|
||||||
|
div.danger p.admonition-title, div.error p.admonition-title,
|
||||||
|
div.warning p.admonition-title, .code .error {
|
||||||
|
color: red ;
|
||||||
|
font-weight: bold ;
|
||||||
|
font-family: sans-serif }
|
||||||
|
|
||||||
|
/* Uncomment (and remove this text!) to get reduced vertical space in
|
||||||
|
compound paragraphs.
|
||||||
|
div.compound .compound-first, div.compound .compound-middle {
|
||||||
|
margin-bottom: 0.5em }
|
||||||
|
|
||||||
|
div.compound .compound-last, div.compound .compound-middle {
|
||||||
|
margin-top: 0.5em }
|
||||||
|
*/
|
||||||
|
|
||||||
|
div.dedication {
|
||||||
|
margin: 2em 5em ;
|
||||||
|
text-align: center ;
|
||||||
|
font-style: italic }
|
||||||
|
|
||||||
|
div.dedication p.topic-title {
|
||||||
|
font-weight: bold ;
|
||||||
|
font-style: normal }
|
||||||
|
|
||||||
|
div.figure {
|
||||||
|
margin-left: 2em ;
|
||||||
|
margin-right: 2em }
|
||||||
|
|
||||||
|
div.footer, div.header {
|
||||||
|
clear: both;
|
||||||
|
font-size: smaller }
|
||||||
|
|
||||||
|
div.line-block {
|
||||||
|
display: block ;
|
||||||
|
margin-top: 1em ;
|
||||||
|
margin-bottom: 1em }
|
||||||
|
|
||||||
|
div.line-block div.line-block {
|
||||||
|
margin-top: 0 ;
|
||||||
|
margin-bottom: 0 ;
|
||||||
|
margin-left: 1.5em }
|
||||||
|
|
||||||
|
div.sidebar {
|
||||||
|
margin: 0 0 0.5em 1em ;
|
||||||
|
border: medium outset ;
|
||||||
|
padding: 1em ;
|
||||||
|
background-color: #ffffee ;
|
||||||
|
width: 40% ;
|
||||||
|
float: right ;
|
||||||
|
clear: right }
|
||||||
|
|
||||||
|
div.sidebar p.rubric {
|
||||||
|
font-family: sans-serif ;
|
||||||
|
font-size: medium }
|
||||||
|
|
||||||
|
div.system-messages {
|
||||||
|
margin: 5em }
|
||||||
|
|
||||||
|
div.system-messages h1 {
|
||||||
|
color: red }
|
||||||
|
|
||||||
|
div.system-message {
|
||||||
|
border: medium outset ;
|
||||||
|
padding: 1em }
|
||||||
|
|
||||||
|
div.system-message p.system-message-title {
|
||||||
|
color: red ;
|
||||||
|
font-weight: bold }
|
||||||
|
|
||||||
|
div.topic {
|
||||||
|
margin: 2em }
|
||||||
|
|
||||||
|
h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
|
||||||
|
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
|
||||||
|
margin-top: 0.4em }
|
||||||
|
|
||||||
|
h1.title {
|
||||||
|
text-align: center }
|
||||||
|
|
||||||
|
h2.subtitle {
|
||||||
|
text-align: center }
|
||||||
|
|
||||||
|
hr.docutils {
|
||||||
|
width: 75% }
|
||||||
|
|
||||||
|
img.align-left, .figure.align-left, object.align-left, table.align-left {
|
||||||
|
clear: left ;
|
||||||
|
float: left ;
|
||||||
|
margin-right: 1em }
|
||||||
|
|
||||||
|
img.align-right, .figure.align-right, object.align-right, table.align-right {
|
||||||
|
clear: right ;
|
||||||
|
float: right ;
|
||||||
|
margin-left: 1em }
|
||||||
|
|
||||||
|
img.align-center, .figure.align-center, object.align-center {
|
||||||
|
display: block;
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.align-center {
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.align-left {
|
||||||
|
text-align: left }
|
||||||
|
|
||||||
|
.align-center {
|
||||||
|
clear: both ;
|
||||||
|
text-align: center }
|
||||||
|
|
||||||
|
.align-right {
|
||||||
|
text-align: right }
|
||||||
|
|
||||||
|
/* reset inner alignment in figures */
|
||||||
|
div.align-right {
|
||||||
|
text-align: inherit }
|
||||||
|
|
||||||
|
/* div.align-center * { */
|
||||||
|
/* text-align: left } */
|
||||||
|
|
||||||
|
.align-top {
|
||||||
|
vertical-align: top }
|
||||||
|
|
||||||
|
.align-middle {
|
||||||
|
vertical-align: middle }
|
||||||
|
|
||||||
|
.align-bottom {
|
||||||
|
vertical-align: bottom }
|
||||||
|
|
||||||
|
ol.simple, ul.simple {
|
||||||
|
margin-bottom: 1em }
|
||||||
|
|
||||||
|
ol.arabic {
|
||||||
|
list-style: decimal }
|
||||||
|
|
||||||
|
ol.loweralpha {
|
||||||
|
list-style: lower-alpha }
|
||||||
|
|
||||||
|
ol.upperalpha {
|
||||||
|
list-style: upper-alpha }
|
||||||
|
|
||||||
|
ol.lowerroman {
|
||||||
|
list-style: lower-roman }
|
||||||
|
|
||||||
|
ol.upperroman {
|
||||||
|
list-style: upper-roman }
|
||||||
|
|
||||||
|
p.attribution {
|
||||||
|
text-align: right ;
|
||||||
|
margin-left: 50% }
|
||||||
|
|
||||||
|
p.caption {
|
||||||
|
font-style: italic }
|
||||||
|
|
||||||
|
p.credits {
|
||||||
|
font-style: italic ;
|
||||||
|
font-size: smaller }
|
||||||
|
|
||||||
|
p.label {
|
||||||
|
white-space: nowrap }
|
||||||
|
|
||||||
|
p.rubric {
|
||||||
|
font-weight: bold ;
|
||||||
|
font-size: larger ;
|
||||||
|
color: maroon ;
|
||||||
|
text-align: center }
|
||||||
|
|
||||||
|
p.sidebar-title {
|
||||||
|
font-family: sans-serif ;
|
||||||
|
font-weight: bold ;
|
||||||
|
font-size: larger }
|
||||||
|
|
||||||
|
p.sidebar-subtitle {
|
||||||
|
font-family: sans-serif ;
|
||||||
|
font-weight: bold }
|
||||||
|
|
||||||
|
p.topic-title {
|
||||||
|
font-weight: bold }
|
||||||
|
|
||||||
|
pre.address {
|
||||||
|
margin-bottom: 0 ;
|
||||||
|
margin-top: 0 ;
|
||||||
|
font: inherit }
|
||||||
|
|
||||||
|
pre.literal-block, pre.doctest-block, pre.math, pre.code {
|
||||||
|
margin-left: 2em ;
|
||||||
|
margin-right: 2em }
|
||||||
|
|
||||||
|
pre.code .ln { color: grey; } /* line numbers */
|
||||||
|
pre.code, code { background-color: #eeeeee }
|
||||||
|
pre.code .comment, code .comment { color: #5C6576 }
|
||||||
|
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
|
||||||
|
pre.code .literal.string, code .literal.string { color: #0C5404 }
|
||||||
|
pre.code .name.builtin, code .name.builtin { color: #352B84 }
|
||||||
|
pre.code .deleted, code .deleted { background-color: #DEB0A1}
|
||||||
|
pre.code .inserted, code .inserted { background-color: #A3D289}
|
||||||
|
|
||||||
|
span.classifier {
|
||||||
|
font-family: sans-serif ;
|
||||||
|
font-style: oblique }
|
||||||
|
|
||||||
|
span.classifier-delimiter {
|
||||||
|
font-family: sans-serif ;
|
||||||
|
font-weight: bold }
|
||||||
|
|
||||||
|
span.interpreted {
|
||||||
|
font-family: sans-serif }
|
||||||
|
|
||||||
|
span.option {
|
||||||
|
white-space: nowrap }
|
||||||
|
|
||||||
|
span.pre {
|
||||||
|
white-space: pre }
|
||||||
|
|
||||||
|
span.problematic {
|
||||||
|
color: red }
|
||||||
|
|
||||||
|
span.section-subtitle {
|
||||||
|
/* font-size relative to parent (h1..h6 element) */
|
||||||
|
font-size: 80% }
|
||||||
|
|
||||||
|
table.citation {
|
||||||
|
border-left: solid 1px gray;
|
||||||
|
margin-left: 1px }
|
||||||
|
|
||||||
|
table.docinfo {
|
||||||
|
margin: 2em 4em }
|
||||||
|
|
||||||
|
table.docutils {
|
||||||
|
margin-top: 0.5em ;
|
||||||
|
margin-bottom: 0.5em }
|
||||||
|
|
||||||
|
table.footnote {
|
||||||
|
border-left: solid 1px black;
|
||||||
|
margin-left: 1px }
|
||||||
|
|
||||||
|
table.docutils td, table.docutils th,
|
||||||
|
table.docinfo td, table.docinfo th {
|
||||||
|
padding-left: 0.5em ;
|
||||||
|
padding-right: 0.5em ;
|
||||||
|
vertical-align: top }
|
||||||
|
|
||||||
|
table.docutils th.field-name, table.docinfo th.docinfo-name {
|
||||||
|
font-weight: bold ;
|
||||||
|
text-align: left ;
|
||||||
|
white-space: nowrap ;
|
||||||
|
padding-left: 0 }
|
||||||
|
|
||||||
|
/* "booktabs" style (no vertical lines) */
|
||||||
|
table.docutils.booktabs {
|
||||||
|
border: 0px;
|
||||||
|
border-top: 2px solid;
|
||||||
|
border-bottom: 2px solid;
|
||||||
|
border-collapse: collapse;
|
||||||
|
}
|
||||||
|
table.docutils.booktabs * {
|
||||||
|
border: 0px;
|
||||||
|
}
|
||||||
|
table.docutils.booktabs th {
|
||||||
|
border-bottom: thin solid;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
|
||||||
|
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
|
||||||
|
font-size: 100% }
|
||||||
|
|
||||||
|
ul.auto-toc {
|
||||||
|
list-style-type: none }
|
||||||
|
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="document" id="hide-portal-module-by-user">
|
||||||
|
<h1 class="title">Hide Portal Module By User</h1>
|
||||||
|
|
||||||
|
<p>Show / Hide Specific Portal Docs on res.users</p>
|
||||||
|
<div class="section" id="important">
|
||||||
|
<h1>IMPORTANT</h1>
|
||||||
|
<p>!! IMPORTANT !!</p>
|
||||||
|
<p>This module doesnt modify the access rights of the users, it only hides the documents.</p>
|
||||||
|
<p>This Module will Allow to enter a specific document via URL even when the user does not have the group assigned to it.</p>
|
||||||
|
<p>REVIEW YOUR USE CASES</p>
|
||||||
|
<p>Example:</p>
|
||||||
|
<p>if you dont have the group assigned to it.</p>
|
||||||
|
<ul class="simple">
|
||||||
|
<li>you can access to the document via URL: /my/orders/6?access_token=0f13c269-0f10-46dc-81f8-4db9682f2267</li>
|
||||||
|
<li>but not to my/orders</li>
|
||||||
|
</ul>
|
||||||
|
<p>PLEASE MAKE A PR IF YOU I MISSED TO WHITELIST A ROUTE URL</p>
|
||||||
|
</div>
|
||||||
|
<div class="section" id="usage">
|
||||||
|
<h1>Usage</h1>
|
||||||
|
<p>To use this module, you need to:</p>
|
||||||
|
<ol class="arabic simple">
|
||||||
|
<li>Install and Configure the Groups and Users</li>
|
||||||
|
</ol>
|
||||||
|
<img alt="hide_portal_module_by_user 1" src="img.png" style="width: 50%;" />
|
||||||
|
<img alt="hide_portal_module_by_user 2" src="img_1.png" style="width: 50%;" />
|
||||||
|
<img alt="hide_portal_module_by_user 3" src="img_2.png" style="width: 50%;" />
|
||||||
|
<img alt="hide_portal_module_by_user 24" src="img_3.png" style="width: 50%;" />
|
||||||
|
<img alt="hide_portal_module_by_user 24" src="img_4.png" style="width: 50%;" />
|
||||||
|
</div>
|
||||||
|
<div class="section" id="how-it-works">
|
||||||
|
<h1>How it Works</h1>
|
||||||
|
<ul class="simple">
|
||||||
|
<li>At Installation, the module will search for all the views that inherits portal.portal_my_home and create a group based on the URL that its linked to in the anchor tag.</li>
|
||||||
|
<li>Post Installation, the module will detect if a new view is created inheriting the portal home and create the group.</li>
|
||||||
|
<li>We Add a validation at view level to hide the group and a validation when trying to list the portal documents.</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div class="section" id="changelog">
|
||||||
|
<h1>Changelog</h1>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
24
hide_portal_module_by_user/views/portal_home.xml
Normal file
24
hide_portal_module_by_user/views/portal_home.xml
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<odoo>
|
||||||
|
<data>
|
||||||
|
<template inherit_id="portal.portal_docs_entry" id="hide_portal_user">
|
||||||
|
<xpath expr="//a" position="replace">
|
||||||
|
<t t-if="request.env.user.validate_portal_url(url)">
|
||||||
|
<a t-att-href="url" t-att-title="title"
|
||||||
|
class="list-group-item list-group-item-action d-flex align-items-center justify-content-between d-none">
|
||||||
|
<t t-esc="title" />
|
||||||
|
<t t-if='count'>
|
||||||
|
<span class="badge text-bg-secondary rounded-pill" t-esc="count" />
|
||||||
|
</t>
|
||||||
|
<t t-elif="placeholder_count">
|
||||||
|
<span class="badge text-bg-secondary rounded-pill"
|
||||||
|
t-att-data-placeholder_count="placeholder_count">
|
||||||
|
<i class="fa fa-spin fa-circle-o-notch"></i>
|
||||||
|
</span>
|
||||||
|
</t>
|
||||||
|
</a>
|
||||||
|
</t>
|
||||||
|
</xpath>
|
||||||
|
</template>
|
||||||
|
</data>
|
||||||
|
</odoo>
|
||||||
28
hide_portal_module_by_user/views/res_groups.xml
Normal file
28
hide_portal_module_by_user/views/res_groups.xml
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright 2026 Munin
|
||||||
|
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
|
||||||
|
|
||||||
|
<odoo>
|
||||||
|
<record model="ir.ui.view" id="res_groups_form_view">
|
||||||
|
<field name="name">res.groups.form (in hide_portal_module_by_user)</field>
|
||||||
|
<field name="model">res.groups</field>
|
||||||
|
<field name="inherit_id" ref="base.view_groups_form"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<field name="share" position="after">
|
||||||
|
<field name="portal_url" readonly="1"
|
||||||
|
attrs="{'invisible':[('portal_url','=',False)]}"/>
|
||||||
|
</field>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
<record model="ir.ui.view" id="res_groups_search_view">
|
||||||
|
<field name="name">res.groups.search (in hide_portal_module_by_user)</field>
|
||||||
|
<field name="model">res.groups</field>
|
||||||
|
<field name="inherit_id" ref="base.view_groups_search"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<field name="share" position="after">
|
||||||
|
<filter name="portal_group" string="Portal Groups"
|
||||||
|
domain="[('portal_url','!=',False)]"/>
|
||||||
|
</field>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</odoo>
|
||||||
Reference in New Issue
Block a user