Before this commit, the project sharing feature is enabled by default when the Project app is installed but the user could never use the feature and thus we add more access rights to portal user for nothing. To avoid this, this commit removes by default all additional access rights given by project sharing feature and adds this access rights only when a collaborator is added. If the user removes all collaborators for all projects then we need to disable the feature. That is, we will remove the access rights and ir.rule records added. So, the feature will not really disable but we remove the additionnal access rights and ir.rule records added with this feature. task-2379518 closes #73341
27 lines
887 B
Python
27 lines
887 B
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from . import controllers
|
|
from . import models
|
|
from . import report
|
|
from . import wizard
|
|
from . import populate
|
|
|
|
from odoo import api, SUPERUSER_ID
|
|
|
|
|
|
def _check_exists_collaborators_for_project_sharing(env):
|
|
""" Check if it exists at least a collaborator in a shared project
|
|
|
|
If it is the case we need to active the portal rules added only for this feature.
|
|
"""
|
|
collaborator = env['project.collaborator'].search([], limit=1)
|
|
if collaborator:
|
|
# Then we need to enable the access rights linked to project sharing for the portal user
|
|
env['project.collaborator']._toggle_project_sharing_portal_rules(True)
|
|
|
|
|
|
def _project_post_init(cr, registry):
|
|
env = api.Environment(cr, SUPERUSER_ID, {})
|
|
_check_exists_collaborators_for_project_sharing(env)
|