[MIG] init 18.0
This commit is contained in:
2
hide_portal_module_by_user/.gitignore
vendored
2
hide_portal_module_by_user/.gitignore
vendored
@@ -1,2 +0,0 @@
|
|||||||
*.*~
|
|
||||||
*pyc
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
==========================
|
|
||||||
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
|
|
||||||
=========
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
from . import models
|
|
||||||
from . import controllers
|
|
||||||
from .hooks import post_init_hook
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
# 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 +0,0 @@
|
|||||||
from . import main
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
# 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()
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
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
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
from . import res_users
|
|
||||||
from . import ir_ui_view
|
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
# 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
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
# 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
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 5.0 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 73 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 93 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 51 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 94 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 71 KiB |
@@ -1,406 +0,0 @@
|
|||||||
<?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>
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
<?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>
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
<?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>
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
====================
|
|
||||||
mail_message_copy_in_partner
|
|
||||||
====================
|
|
||||||
|
|
||||||
Installation
|
|
||||||
============
|
|
||||||
Use Odoo normal module installation procedure to install ``mail_message_copy_in_partner``.
|
|
||||||
|
|
||||||
|
|
||||||
Configuration
|
|
||||||
=============
|
|
||||||
|
|
||||||
Nothing to do
|
|
||||||
|
|
||||||
|
|
||||||
Usage
|
|
||||||
=====
|
|
||||||
If module is installed, notes will never send email to partners not linked to internal users.
|
|
||||||
|
|
||||||
|
|
||||||
Known issues / Roadmap
|
|
||||||
======================
|
|
||||||
|
|
||||||
None yet.
|
|
||||||
|
|
||||||
Bug Tracker
|
|
||||||
===========
|
|
||||||
|
|
||||||
Bugs are tracked on `our issues website <https://github.com/elabore-coop/ux-tools/issues>`_. In case of
|
|
||||||
trouble, please check there if your issue has already been
|
|
||||||
reported. If you spotted it first, help us smashing it by providing a
|
|
||||||
detailed and welcomed feedback.
|
|
||||||
|
|
||||||
Credits
|
|
||||||
=======
|
|
||||||
|
|
||||||
Contributors
|
|
||||||
------------
|
|
||||||
|
|
||||||
* Clément Thomas
|
|
||||||
|
|
||||||
Funders
|
|
||||||
-------
|
|
||||||
|
|
||||||
The development of this module has been financially supported by:
|
|
||||||
* Elabore (https://elabore.coop)
|
|
||||||
|
|
||||||
|
|
||||||
Maintainer
|
|
||||||
----------
|
|
||||||
|
|
||||||
This module is maintained by Elabore.
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
||||||
|
|
||||||
from . import models
|
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
# Copyright 2022 Laetitia Élabore (Elabore)
|
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
||||||
|
|
||||||
{
|
|
||||||
"name": "mail_message_copy_in_partner",
|
|
||||||
"version": "16.0.1.0.0",
|
|
||||||
"author": "Elabore",
|
|
||||||
"website": "https://github.com/elabore-coop/ux-tools",
|
|
||||||
"maintainer": "Clément",
|
|
||||||
"license": "AGPL-3",
|
|
||||||
"category": "Tools",
|
|
||||||
"summary": "If current model has partner_id field, all messages will be copied in partner's chatter",
|
|
||||||
"description": """
|
|
||||||
:image: https://img.shields.io/badge/licence-AGPL--3-blue.svg
|
|
||||||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
|
||||||
:alt: License: AGPL-3
|
|
||||||
=================
|
|
||||||
mail_message_copy_in_partner
|
|
||||||
=================
|
|
||||||
If current model has partner_id field, all messages will be copied in partner's chatter
|
|
||||||
New message is a note without recipients
|
|
||||||
|
|
||||||
|
|
||||||
Installation
|
|
||||||
============
|
|
||||||
|
|
||||||
Install ``mail_message_copy_in_partner``, all dependencies will be installed by default.
|
|
||||||
|
|
||||||
Known issues / Roadmap
|
|
||||||
======================
|
|
||||||
|
|
||||||
None yet.
|
|
||||||
|
|
||||||
Bug Tracker
|
|
||||||
===========
|
|
||||||
|
|
||||||
Bugs are tracked on `our issues website
|
|
||||||
<https://github.com/elabore-coop/ux-tools/issues>`_. In case of
|
|
||||||
trouble, please check there if your issue has already been
|
|
||||||
reported. If you spotted it first, help us smashing it by providing a
|
|
||||||
detailed and welcomed feedback.
|
|
||||||
|
|
||||||
Credits
|
|
||||||
=======
|
|
||||||
|
|
||||||
Images
|
|
||||||
------
|
|
||||||
|
|
||||||
* Elabore: `Icon <https://elabore.coop/web/image/res.company/1/logo?unique=f3db262>`_.
|
|
||||||
|
|
||||||
Contributors
|
|
||||||
------------
|
|
||||||
|
|
||||||
* Clément Thomas
|
|
||||||
|
|
||||||
Funders
|
|
||||||
-------
|
|
||||||
|
|
||||||
The development of this module has been financially supported by:
|
|
||||||
* Elabore (https://elabore.coop)
|
|
||||||
|
|
||||||
|
|
||||||
Maintainer
|
|
||||||
----------
|
|
||||||
This module is maintained by Elabore.
|
|
||||||
|
|
||||||
""",
|
|
||||||
# any module necessary for this one to work correctly
|
|
||||||
'depends' : ['base_setup'],
|
|
||||||
"qweb": [
|
|
||||||
# "static/src/xml/*.xml",
|
|
||||||
],
|
|
||||||
"external_dependencies": {
|
|
||||||
"python": [],
|
|
||||||
},
|
|
||||||
# always loaded
|
|
||||||
"data": [
|
|
||||||
|
|
||||||
],
|
|
||||||
# only loaded in demonstration mode
|
|
||||||
"demo": [],
|
|
||||||
"js": [],
|
|
||||||
"css": [],
|
|
||||||
"installable": True,
|
|
||||||
# Install this module automatically if all dependency have been previously
|
|
||||||
# and independently installed. Used for synergetic or glue modules.
|
|
||||||
"auto_install": False,
|
|
||||||
"application": False,
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
from . import mail_thread
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
from odoo import api, models, _
|
|
||||||
|
|
||||||
|
|
||||||
class MailThread(models.AbstractModel):
|
|
||||||
_inherit = 'mail.thread'
|
|
||||||
|
|
||||||
@api.returns('mail.message', lambda value: value.id)
|
|
||||||
def message_post(self, body='', **kwargs):
|
|
||||||
#send message to related partner
|
|
||||||
if hasattr(self, 'partner_id') and self.partner_id:
|
|
||||||
msg = _('<b>[%(object)s]</b> %(body)s',object=self._get_html_link(), body=body)
|
|
||||||
|
|
||||||
new_kwargs = kwargs.copy()
|
|
||||||
|
|
||||||
#new message is a note
|
|
||||||
new_kwargs['subtype_xmlid'] = "mail.mt_note"
|
|
||||||
|
|
||||||
#do not send anything
|
|
||||||
new_kwargs['partner_ids'] = []
|
|
||||||
|
|
||||||
self.partner_id.message_post(body=msg, **new_kwargs)
|
|
||||||
|
|
||||||
return super(MailThread, self).message_post(body=body, **kwargs)
|
|
||||||
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
====================
|
|
||||||
mail_prevent_send_note_to_external
|
|
||||||
====================
|
|
||||||
|
|
||||||
Installation
|
|
||||||
============
|
|
||||||
Use Odoo normal module installation procedure to install ``mail_prevent_send_note_to_external``.
|
|
||||||
|
|
||||||
|
|
||||||
Configuration
|
|
||||||
=============
|
|
||||||
|
|
||||||
Nothing to do
|
|
||||||
|
|
||||||
|
|
||||||
Usage
|
|
||||||
=====
|
|
||||||
If module is installed, notes will never send email to partners not linked to internal users.
|
|
||||||
|
|
||||||
|
|
||||||
Known issues / Roadmap
|
|
||||||
======================
|
|
||||||
|
|
||||||
None yet.
|
|
||||||
|
|
||||||
Bug Tracker
|
|
||||||
===========
|
|
||||||
|
|
||||||
Bugs are tracked on `our issues website <https://github.com/elabore-coop/ux-tools/issues>`_. In case of
|
|
||||||
trouble, please check there if your issue has already been
|
|
||||||
reported. If you spotted it first, help us smashing it by providing a
|
|
||||||
detailed and welcomed feedback.
|
|
||||||
|
|
||||||
Credits
|
|
||||||
=======
|
|
||||||
|
|
||||||
Contributors
|
|
||||||
------------
|
|
||||||
|
|
||||||
* Clément Thomas
|
|
||||||
|
|
||||||
Funders
|
|
||||||
-------
|
|
||||||
|
|
||||||
The development of this module has been financially supported by:
|
|
||||||
* Elabore (https://elabore.coop)
|
|
||||||
|
|
||||||
|
|
||||||
Maintainer
|
|
||||||
----------
|
|
||||||
|
|
||||||
This module is maintained by Elabore.
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
||||||
|
|
||||||
from . import models
|
|
||||||
@@ -1,88 +0,0 @@
|
|||||||
# Copyright 2022 Laetitia Élabore (Elabore)
|
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
||||||
|
|
||||||
{
|
|
||||||
"name": "mail_prevent_send_note_to_external",
|
|
||||||
"version": "16.0.1.0.0",
|
|
||||||
"author": "Elabore",
|
|
||||||
"website": "https://github.com/elabore-coop/ux-tools",
|
|
||||||
"maintainer": "Clément",
|
|
||||||
"license": "AGPL-3",
|
|
||||||
"category": "Tools",
|
|
||||||
"summary": "Prevent chatter note to send email to external partner",
|
|
||||||
"description": """
|
|
||||||
:image: https://img.shields.io/badge/licence-AGPL--3-blue.svg
|
|
||||||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
|
||||||
:alt: License: AGPL-3
|
|
||||||
=================
|
|
||||||
mail_prevent_send_note_to_external
|
|
||||||
=================
|
|
||||||
|
|
||||||
Prevent chatter note to send email to external partner
|
|
||||||
|
|
||||||
Installation
|
|
||||||
============
|
|
||||||
|
|
||||||
Install ``mail_prevent_send_note_to_external``, all dependencies will be installed by default.
|
|
||||||
|
|
||||||
Known issues / Roadmap
|
|
||||||
======================
|
|
||||||
|
|
||||||
None yet.
|
|
||||||
|
|
||||||
Bug Tracker
|
|
||||||
===========
|
|
||||||
|
|
||||||
Bugs are tracked on `our issues website
|
|
||||||
<https://github.com/elabore-coop/ux-tools/issues>`_. In case of
|
|
||||||
trouble, please check there if your issue has already been
|
|
||||||
reported. If you spotted it first, help us smashing it by providing a
|
|
||||||
detailed and welcomed feedback.
|
|
||||||
|
|
||||||
Credits
|
|
||||||
=======
|
|
||||||
|
|
||||||
Images
|
|
||||||
------
|
|
||||||
|
|
||||||
* Elabore: `Icon <https://elabore.coop/web/image/res.company/1/logo?unique=f3db262>`_.
|
|
||||||
|
|
||||||
Contributors
|
|
||||||
------------
|
|
||||||
|
|
||||||
* Clément Thomas
|
|
||||||
|
|
||||||
Funders
|
|
||||||
-------
|
|
||||||
|
|
||||||
The development of this module has been financially supported by:
|
|
||||||
* Elabore (https://elabore.coop)
|
|
||||||
|
|
||||||
|
|
||||||
Maintainer
|
|
||||||
----------
|
|
||||||
This module is maintained by Elabore.
|
|
||||||
|
|
||||||
""",
|
|
||||||
# any module necessary for this one to work correctly
|
|
||||||
'depends' : ['base_setup'],
|
|
||||||
"qweb": [
|
|
||||||
# "static/src/xml/*.xml",
|
|
||||||
],
|
|
||||||
"external_dependencies": {
|
|
||||||
"python": [],
|
|
||||||
},
|
|
||||||
# always loaded
|
|
||||||
"data": [
|
|
||||||
|
|
||||||
],
|
|
||||||
# only loaded in demonstration mode
|
|
||||||
"demo": [],
|
|
||||||
"js": [],
|
|
||||||
"css": [],
|
|
||||||
"installable": True,
|
|
||||||
# Install this module automatically if all dependency have been previously
|
|
||||||
# and independently installed. Used for synergetic or glue modules.
|
|
||||||
"auto_install": False,
|
|
||||||
"application": False,
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
from . import mail_thread
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
from odoo import api, models, _
|
|
||||||
|
|
||||||
|
|
||||||
class MailThread(models.AbstractModel):
|
|
||||||
_inherit = 'mail.thread'
|
|
||||||
|
|
||||||
@api.returns('mail.message', lambda value: value.id)
|
|
||||||
def message_post(self, **kwargs):
|
|
||||||
#check subtype_xmlid and partner_ids, and remove external partners if subtype is "note"
|
|
||||||
if kwargs.get("subtype_xmlid") == 'mail.mt_note' and "partner_ids" in kwargs:
|
|
||||||
new_partner_ids = []
|
|
||||||
for partner_id in kwargs["partner_ids"]:
|
|
||||||
user = self.env["res.users"].search([('partner_id','=',partner_id)])
|
|
||||||
if user.active and user.has_group('base.group_user'):
|
|
||||||
new_partner_ids.append(partner_id)
|
|
||||||
kwargs["partner_ids"] = new_partner_ids
|
|
||||||
|
|
||||||
message = super(MailThread, self).message_post(**kwargs)
|
|
||||||
return message
|
|
||||||
Reference in New Issue
Block a user