[CLN] remove unmigrate now : project_visibility_followers_portal
A branch is created with WIP
This commit is contained in:
@@ -1,45 +0,0 @@
|
||||
=================
|
||||
project_visibility_followers_portal
|
||||
=================
|
||||
|
||||
Add project visibility : some employees and some portal users
|
||||
|
||||
Installation
|
||||
============
|
||||
|
||||
Use Odoo normal procedure to install add-ons to install
|
||||
``project_visibility_followers_portal``.
|
||||
|
||||
Known issues / Roadmap
|
||||
======================
|
||||
|
||||
Bug Tracker
|
||||
===========
|
||||
|
||||
Bugs are tracked on `our issues website
|
||||
<https://github.com/elabore-coop/project-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.
|
@@ -1,3 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import models
|
@@ -1,92 +0,0 @@
|
||||
# Copyright 2022 Stéphan Sainléger (Elabore)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
{
|
||||
"name": "project_visibility_followers_portal",
|
||||
"version": "14.0.1.0.0",
|
||||
"author": "Elabore",
|
||||
"website": "https://github.com/elabore-coop/project-tools",
|
||||
"maintainer": "Clément Thomas",
|
||||
"license": "AGPL-3",
|
||||
"category": "Tools",
|
||||
"summary": "Add project visibility : some employees and some portal users",
|
||||
"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
|
||||
=================
|
||||
project_visibility_followers_portal
|
||||
=================
|
||||
|
||||
Add project visibility : some employees and some portal users
|
||||
|
||||
Installation
|
||||
============
|
||||
|
||||
Install ``project_visibility_followers_portal``, 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/project-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",
|
||||
"project",
|
||||
],
|
||||
"qweb": [
|
||||
# "static/src/xml/*.xml",
|
||||
],
|
||||
"external_dependencies": {
|
||||
"python": [],
|
||||
},
|
||||
# always loaded
|
||||
"data": [
|
||||
"views/project_views.xml",
|
||||
"security/project_security.xml"
|
||||
],
|
||||
# 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,100 +0,0 @@
|
||||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * project_visibility_followers_portal
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 14.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2023-05-22 13:09+0000\n"
|
||||
"PO-Revision-Date: 2023-05-22 13:09+0000\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Plural-Forms: \n"
|
||||
|
||||
#. module: project_visibility_followers_portal
|
||||
#: model:ir.model.fields,field_description:project_visibility_followers_portal.field_project_project__display_name
|
||||
#: model:ir.model.fields,field_description:project_visibility_followers_portal.field_project_task__display_name
|
||||
msgid "Display Name"
|
||||
msgstr "Nom affiché"
|
||||
|
||||
#. module: project_visibility_followers_portal
|
||||
#: model:ir.model.fields,field_description:project_visibility_followers_portal.field_project_project__id
|
||||
#: model:ir.model.fields,field_description:project_visibility_followers_portal.field_project_task__id
|
||||
msgid "ID"
|
||||
msgstr ""
|
||||
|
||||
#. module: project_visibility_followers_portal
|
||||
#: model:ir.model.fields.selection,name:project_visibility_followers_portal.selection__project_project__privacy_visibility__followers_portal
|
||||
msgid "Invited portal users and invited internal users"
|
||||
msgstr "Utilisateurs portail invités et utilisateurs internes invités"
|
||||
|
||||
#. module: project_visibility_followers_portal
|
||||
#: model:ir.model.fields,field_description:project_visibility_followers_portal.field_project_project____last_update
|
||||
#: model:ir.model.fields,field_description:project_visibility_followers_portal.field_project_task____last_update
|
||||
msgid "Last Modified on"
|
||||
msgstr "Dernière modification le"
|
||||
|
||||
#. module: project_visibility_followers_portal
|
||||
#: model:ir.model.fields,help:project_visibility_followers_portal.field_project_project__privacy_visibility
|
||||
msgid ""
|
||||
"People to whom this project and its tasks will be visible.\n"
|
||||
"\n"
|
||||
"- Invited internal users: when following a project, internal users will get access to all of its tasks without distinction. Otherwise, they will only get access to the specific tasks they are following.\n"
|
||||
" A user with the project > administrator access right level can still access this project and its tasks, even if they are not explicitly part of the followers.\n"
|
||||
"\n"
|
||||
"- All internal users: all internal users can access the project and all of its tasks without distinction.\n"
|
||||
"\n"
|
||||
"- Invited portal users and all internal users: all internal users can access the project and all of its tasks without distinction.\n"
|
||||
"When following a project, portal users will get access to all of its tasks without distinction. Otherwise, they will only get access to the specific tasks they are following."
|
||||
msgstr ""
|
||||
"Personnes pour lesquelles ce projet et ses tâches seront visibles.\n"
|
||||
"\n"
|
||||
"- Utilisateurs internes invités : lorsqu'ils sont abonnés à un projet, les utilisateurs internes auront accès à toutes ses tâches sans distinction. Autrement, ils auront uniquement accès aux tâches spécifiques auxquelles ils sont abonnés.\n"
|
||||
" Un utilisateur avec le niveau de droits d'accès projet > administrateur peut toujours accéder au projet et à ses tâches, même s'il ne fait pas explicitement partie des abonnés.\n"
|
||||
"\n"
|
||||
"- Tous les utilisateurs internes : tous les utilisateurs internes peuvent accéder au projet et à toutes ses tâches sans distinction.\n"
|
||||
"\n"
|
||||
"- Les utilisateurs portail invités et tous les utilisateurs internes : tous les utilisateurs internes peuvent accéder au projet et à toutes ses tâches sans distinction.\n"
|
||||
"Quand ils suivent un projet, les utilisateurs portail auront accès à toutes ses tâches sans distinction. Autrement, ils auront uniquement accès aux tâches spécifiques auxquelles ils sont abonnés."
|
||||
|
||||
#. module: project_visibility_followers_portal
|
||||
#: model:ir.model,name:project_visibility_followers_portal.model_project_project
|
||||
msgid "Project"
|
||||
msgstr "Projet"
|
||||
|
||||
#. module: project_visibility_followers_portal
|
||||
#: model:ir.model,name:project_visibility_followers_portal.model_project_task
|
||||
msgid "Task"
|
||||
msgstr "Tâche"
|
||||
|
||||
#. module: project_visibility_followers_portal
|
||||
#: code:addons/project_visibility_followers_portal/models/project_task.py:0
|
||||
#, python-format
|
||||
msgid ""
|
||||
"The project visibility setting doesn't allow portal users to see the "
|
||||
"project's tasks. (%s)"
|
||||
msgstr ""
|
||||
"Le paramètre de visibilité du projet ne permet pas aux utilisateurs portail "
|
||||
"de voir les tâches du projet. (%s)"
|
||||
|
||||
#. module: project_visibility_followers_portal
|
||||
#: code:addons/project_visibility_followers_portal/models/project_task.py:0
|
||||
#, python-format
|
||||
msgid ""
|
||||
"The task cannot be shared with the recipient(s) because the privacy of the "
|
||||
"project is too restricted. Set the privacy of the project to 'Visible by "
|
||||
"following customers' in order to make it accessible by the recipient(s)."
|
||||
msgstr ""
|
||||
"La tâche ne peut pas être partagée avec le(s) destinataire(s) car la "
|
||||
"confidentialité du projet est trop restreinte. Définissez la confidentialité"
|
||||
" sur \"Visible par les clients suiveurs\" afin de la rendre accessible au(x)"
|
||||
" destinataire(s)."
|
||||
|
||||
#. module: project_visibility_followers_portal
|
||||
#: model:ir.model.fields,field_description:project_visibility_followers_portal.field_project_project__privacy_visibility
|
||||
msgid "Visibility"
|
||||
msgstr "Visibilité"
|
@@ -1,2 +0,0 @@
|
||||
|
||||
from . import project_project, project_task
|
@@ -1,30 +0,0 @@
|
||||
|
||||
from odoo import models, fields, api
|
||||
|
||||
|
||||
class Project(models.Model):
|
||||
_inherit = "project.project"
|
||||
|
||||
privacy_visibility = fields.Selection(
|
||||
selection_add=[('followers_portal','Invited portal users and invited internal users')],
|
||||
ondelete={'followers_portal': 'set default'})
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
"""In case of "followers_portal" privacy visibility, add current user to list of allowed users.
|
||||
Same behaviour than "portal" privacy visibility.
|
||||
"""
|
||||
project = super(Project, self).create(vals)
|
||||
if project.privacy_visibility == 'followers_portal' and project.partner_id.user_ids:
|
||||
project.allowed_user_ids |= project.partner_id.user_ids
|
||||
return project
|
||||
|
||||
def write(self, vals):
|
||||
"""In case of "followers_portal" privacy visibility, add current user to list of allowed users.
|
||||
Same behaviour than "portal" privacy visibility.
|
||||
"""
|
||||
res = super(Project, self).write(vals)
|
||||
if vals.get('partner_id') or vals.get('privacy_visibility'):
|
||||
for project in self.filtered(lambda project: project.privacy_visibility == 'followers_portal'):
|
||||
project.allowed_user_ids |= project.partner_id.user_ids
|
||||
return res
|
@@ -1,89 +0,0 @@
|
||||
|
||||
from odoo import models, fields, api, _
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
class Task(models.Model):
|
||||
_inherit = "project.task"
|
||||
|
||||
@api.constrains('allowed_user_ids')
|
||||
def _check_no_portal_allowed(self):
|
||||
for task in self.filtered(lambda t: t.project_id.privacy_visibility not in ('portal','followers_portal')):
|
||||
portal_users = task.allowed_user_ids.filtered('share')
|
||||
if portal_users:
|
||||
user_names = ', '.join(portal_users[:10].mapped('name'))
|
||||
raise ValidationError(_("The project visibility setting doesn't allow portal users to see the project's tasks. (%s)", user_names))
|
||||
|
||||
@api.depends('project_id.allowed_user_ids', 'project_id.privacy_visibility')
|
||||
def _compute_allowed_user_ids(self):
|
||||
for task in self.with_context(prefetch_fields=False):
|
||||
portal_users = task.allowed_user_ids.filtered('share')
|
||||
internal_users = task.allowed_user_ids - portal_users
|
||||
|
||||
if task.project_id.privacy_visibility == 'followers':
|
||||
task.allowed_user_ids |= task.project_id.allowed_internal_user_ids
|
||||
task.allowed_user_ids -= portal_users
|
||||
elif task.project_id.privacy_visibility == 'portal':
|
||||
task.allowed_user_ids |= task.project_id.allowed_portal_user_ids
|
||||
elif task.project_id.privacy_visibility == 'followers_portal':
|
||||
task.allowed_user_ids |= task.project_id.allowed_internal_user_ids
|
||||
task.allowed_user_ids |= task.project_id.allowed_portal_user_ids
|
||||
|
||||
if task.project_id.privacy_visibility not in ('portal','followers_portal'):
|
||||
task.allowed_user_ids -= portal_users
|
||||
elif task.project_id.privacy_visibility not in ('followers','followers_portal'):
|
||||
task.allowed_user_ids -= internal_users
|
||||
|
||||
def _compute_access_warning(self):
|
||||
for task in self.filtered(lambda x: x.project_id.privacy_visibility not in ('portal','followers_portal')):
|
||||
task.access_warning = _(
|
||||
"The task cannot be shared with the recipient(s) because the privacy of the project is too restricted. Set the privacy of the project to 'Visible by following customers' in order to make it accessible by the recipient(s).")
|
||||
|
||||
def message_subscribe(self, partner_ids=None, channel_ids=None, subtype_ids=None):
|
||||
"""
|
||||
Add the users subscribed to allowed portal users
|
||||
"""
|
||||
res = super(Task, self).message_subscribe(partner_ids=partner_ids, channel_ids=channel_ids, subtype_ids=subtype_ids)
|
||||
if partner_ids:
|
||||
new_allowed_users = self.env['res.partner'].browse(partner_ids).user_ids.filtered('share')
|
||||
tasks = self.filtered(lambda task: task.project_id.privacy_visibility == 'followers_portal')
|
||||
tasks.sudo().allowed_user_ids |= new_allowed_users
|
||||
return res
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
tasks = super(Task, self).create(vals_list)
|
||||
for task in tasks:
|
||||
if task.project_id.privacy_visibility == 'followers_portal':
|
||||
task._portal_ensure_token()
|
||||
return tasks
|
||||
|
||||
def _notify_get_groups(self, msg_vals=None):
|
||||
groups = super(Task, self)._notify_get_groups(msg_vals=msg_vals)
|
||||
""" Handle project users and managers recipients that can assign
|
||||
tasks and create new one directly from notification emails. Also give
|
||||
access button to portal users and portal customers. If they are notified
|
||||
they should probably have access to the document. """
|
||||
self.ensure_one()
|
||||
|
||||
project_user_group_id = self.env.ref('project.group_project_user').id
|
||||
project_manager_group_id = self.env.ref('project.group_project_manager').id
|
||||
|
||||
group_func = lambda pdata: pdata['type'] == 'user' and project_user_group_id in pdata['groups']
|
||||
if self.project_id.privacy_visibility == 'followers_portal':
|
||||
allowed_user_ids = self.project_id.allowed_internal_user_ids.partner_id.ids
|
||||
group_func = lambda pdata:\
|
||||
pdata['type'] == 'user'\
|
||||
and (
|
||||
project_manager_group_id in pdata['groups']\
|
||||
or (project_user_group_id in pdata['groups'] and pdata['id'] in allowed_user_ids)
|
||||
)
|
||||
groups = [('group_project_user', group_func, {})]+groups
|
||||
allowed_user_ids = self.project_id.allowed_portal_user_ids.partner_id.ids
|
||||
groups.insert(0, (
|
||||
'allowed_portal_users',
|
||||
lambda pdata: pdata['type'] == 'portal' and pdata['id'] in allowed_user_ids,
|
||||
{}
|
||||
))
|
||||
|
||||
return groups
|
@@ -1,54 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<data noupdate="0">
|
||||
|
||||
<record model="ir.rule" id="project_project_rule_followers_portal">
|
||||
<field name="name">Project: Invited internal users and invited portal users</field>
|
||||
<field name="model_id" ref="model_project_project"/>
|
||||
<field name="domain_force">[
|
||||
('privacy_visibility', '=', 'followers_portal'),
|
||||
'|', ('allowed_portal_user_ids', 'in', user.ids),
|
||||
('allowed_internal_user_ids', 'in', user.ids),
|
||||
]</field>
|
||||
<field name="groups" eval="[(4, ref('base.group_user')),(4, ref('base.group_portal'))]"/>
|
||||
</record>
|
||||
|
||||
<record model="ir.rule" id="project_task_rule_followers_portal">
|
||||
<field name="name">Task: Invited internal users and invited portal users</field>
|
||||
<field name="model_id" ref="model_project_task"/>
|
||||
<field name="domain_force">[
|
||||
('project_id.privacy_visibility', '=', 'followers_portal'),
|
||||
('allowed_user_ids', 'in', user.ids),
|
||||
]</field>
|
||||
<field name="groups" eval="[(4, ref('base.group_user')),(4, ref('base.group_portal'))]"/>
|
||||
</record>
|
||||
|
||||
<!-- change existing rule -->
|
||||
<record model="ir.rule" id="project.project_public_members_rule">
|
||||
<field name="domain_force">[
|
||||
'|',
|
||||
('privacy_visibility', '!=', 'followers_portal'),
|
||||
('allowed_internal_user_ids', 'in', user.ids),
|
||||
'|',
|
||||
('privacy_visibility', '!=', 'followers'),
|
||||
('allowed_internal_user_ids', 'in', user.ids),
|
||||
]</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.rule" id="project.task_visibility_rule">
|
||||
<field name="domain_force">[
|
||||
'|',
|
||||
('project_id.privacy_visibility', '!=', 'followers_portal'),
|
||||
('allowed_user_ids', 'in', user.ids),
|
||||
'|',
|
||||
('project_id.privacy_visibility', '!=', 'followers'),
|
||||
('allowed_user_ids', 'in', user.ids),
|
||||
]</field>
|
||||
<field name="groups" eval="[(4,ref('base.group_user'))]"/>
|
||||
</record>
|
||||
|
||||
|
||||
|
||||
</data>
|
||||
</odoo>
|
@@ -1,20 +0,0 @@
|
||||
<!-- todo: remove the date_start and date_end from the Extra Info Tab -->
|
||||
<odoo>
|
||||
<data>
|
||||
|
||||
<record id="view_project_form_visibility_followers_portal" model="ir.ui.view">
|
||||
<field name="name">project.form.visibility.followers.portal</field>
|
||||
<field name="model">project.project</field>
|
||||
<field name="inherit_id" ref="project.edit_project"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='allowed_internal_user_ids']" position="attributes">
|
||||
<attribute name="attrs">{'invisible': [('privacy_visibility', '!=', 'followers'),('privacy_visibility', '!=', 'followers_portal')]}</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='allowed_portal_user_ids']" position="attributes">
|
||||
<attribute name="attrs">{'invisible': [('privacy_visibility', '!=', 'portal'),('privacy_visibility', '!=', 'followers_portal')]}</attribute>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</odoo>
|
Reference in New Issue
Block a user