Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions project_share/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
=============
Project Share
=============

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:728663946988f1ca9235b8189903e7c22071abd089f85f75a3c954c3774e2b1b
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fproject-lightgray.png?logo=github
:target: https://github.com/OCA/project/tree/17.0/project_share
:alt: OCA/project
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/project-17-0/project-17-0-project_share
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/project&target_branch=17.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module adds a new functionality on collaborators, so we can have
readonly collaborators that are able to see kanban and list views in the
same way we have in internal view.

**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/project/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/project/issues/new?body=module:%20project_share%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* Dixmit

Contributors
------------

- `Dixmit <https://www.dixmit.com>`__

- Enric Tobella

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/project <https://github.com/OCA/project/tree/17.0/project_share>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions project_share/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import controllers
from . import models
from .hooks import post_init_hook
22 changes: 22 additions & 0 deletions project_share/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2025 Dixmit
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Project Share",
"summary": """
Improve the Share view of projects,
showing the kanban view on readonly too
""",
"version": "17.0.1.0.0",
"license": "AGPL-3",
"author": "Dixmit,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/project",
"depends": [
"project",
],
"data": [
"views/project_collaborator.xml",
],
"demo": [],
"post_init_hook": "post_init_hook",
}
1 change: 1 addition & 0 deletions project_share/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import portal
14 changes: 14 additions & 0 deletions project_share/controllers/portal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2025 Dixmit
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).


from odoo.addons.project.controllers.portal import ProjectCustomerPortal


class ProjectSharePortal(ProjectCustomerPortal):
def _prepare_project_sharing_session_info(self, project, task=None):
res = super()._prepare_project_sharing_session_info(project, task=task)
res["user_context"]["draggable"] = bool(
project._check_project_sharing_access(check_readonly=True)
)
return res
19 changes: 19 additions & 0 deletions project_share/hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
def post_init_hook(env):
env.ref("project.project_task_rule_portal_project_sharing").write(
{
"domain_force": """
[
('project_id.privacy_visibility', '=', 'portal'),
('active', '=', True),
'|',
('project_id.message_partner_ids',
'child_of',
[user.partner_id.commercial_partner_id.id]),
('message_partner_ids',
'child_of',
[user.partner_id.commercial_partner_id.id]),
('project_id.edit_collaborator_ids.partner_id', 'in', [user.partner_id.id]),
]
"""
}
)
3 changes: 3 additions & 0 deletions project_share/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import project_project
from . import project_collaborator
from . import project_task
10 changes: 10 additions & 0 deletions project_share/models/project_collaborator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright 2025 Dixmit
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class ProjectCollaborator(models.Model):
_inherit = "project.collaborator"

readonly = fields.Boolean(default=False)
26 changes: 26 additions & 0 deletions project_share/models/project_project.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright 2025 Dixmit
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class ProjectProject(models.Model):
_inherit = "project.project"

edit_collaborator_ids = fields.One2many(
"project.collaborator",
"project_id",
string="Collaborators",
copy=False,
domain=[("readonly", "=", False)],
)

def _check_project_sharing_access(self, check_readonly=False):
result = super()._check_project_sharing_access()
if (
check_readonly
and isinstance(result, models.BaseModel)
and result._name == "project.collaborator"
):
return result.filtered(lambda c: not c.readonly)
return result
51 changes: 51 additions & 0 deletions project_share/models/project_task.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Copyright 2025 Dixmit
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from lxml import etree

from odoo import api, models


class ProjectTask(models.Model):
_inherit = "project.task"

@api.model
def get_view(self, view_id=None, view_type="form", **options):
result = super().get_view(view_id=view_id, view_type=view_type, **options)
if (
view_type == "kanban"
and view_id
== self.env.ref("project.project_sharing_project_task_view_kanban").id
and not self.env.context.get("draggable")
):
doc = etree.XML(result["arch"])
nodes = doc.xpath("//kanban")
if nodes:
nodes[0].set("records_draggable", "0")
nodes[0].set("create", "0")
result["arch"] = etree.tostring(doc, encoding="unicode")
if (
view_type == "form"
and view_id
== self.env.ref("project.project_sharing_project_task_view_form").id
and not self.env.context.get("draggable")
):
doc = etree.XML(result["arch"])
nodes = doc.xpath("//form")
if nodes:
nodes[0].set("edit", "0")
nodes[0].set("create", "0")
result["arch"] = etree.tostring(doc, encoding="unicode")
if (
view_type == "tree"
and view_id
== self.env.ref("project.project_sharing_project_task_view_tree").id
and not self.env.context.get("draggable")
):
doc = etree.XML(result["arch"])
nodes = doc.xpath("//tree")
if nodes:
nodes[0].set("edit", "0")
nodes[0].set("create", "0")
result["arch"] = etree.tostring(doc, encoding="unicode")
return result
3 changes: 3 additions & 0 deletions project_share/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
2 changes: 2 additions & 0 deletions project_share/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- [Dixmit](https://www.dixmit.com)
- Enric Tobella
1 change: 1 addition & 0 deletions project_share/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This module adds a new functionality on collaborators, so we can have readonly collaborators that are able to see kanban and list views in the same way we have in internal view.
Binary file added project_share/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading