diff --git a/project_share/README.rst b/project_share/README.rst new file mode 100644 index 0000000000..cd6a34f334 --- /dev/null +++ b/project_share/README.rst @@ -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 `_. +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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Dixmit + +Contributors +------------ + +- `Dixmit `__ + + - 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 `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/project_share/__init__.py b/project_share/__init__.py new file mode 100644 index 0000000000..6487efb0df --- /dev/null +++ b/project_share/__init__.py @@ -0,0 +1,3 @@ +from . import controllers +from . import models +from .hooks import post_init_hook diff --git a/project_share/__manifest__.py b/project_share/__manifest__.py new file mode 100644 index 0000000000..bcf95cd780 --- /dev/null +++ b/project_share/__manifest__.py @@ -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", +} diff --git a/project_share/controllers/__init__.py b/project_share/controllers/__init__.py new file mode 100644 index 0000000000..8c3feb6f56 --- /dev/null +++ b/project_share/controllers/__init__.py @@ -0,0 +1 @@ +from . import portal diff --git a/project_share/controllers/portal.py b/project_share/controllers/portal.py new file mode 100644 index 0000000000..f3dce150df --- /dev/null +++ b/project_share/controllers/portal.py @@ -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 diff --git a/project_share/hooks.py b/project_share/hooks.py new file mode 100644 index 0000000000..4934a0cc8e --- /dev/null +++ b/project_share/hooks.py @@ -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]), + ] + """ + } + ) diff --git a/project_share/models/__init__.py b/project_share/models/__init__.py new file mode 100644 index 0000000000..6b1f9e7fd6 --- /dev/null +++ b/project_share/models/__init__.py @@ -0,0 +1,3 @@ +from . import project_project +from . import project_collaborator +from . import project_task diff --git a/project_share/models/project_collaborator.py b/project_share/models/project_collaborator.py new file mode 100644 index 0000000000..111e662e91 --- /dev/null +++ b/project_share/models/project_collaborator.py @@ -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) diff --git a/project_share/models/project_project.py b/project_share/models/project_project.py new file mode 100644 index 0000000000..547ca6aadb --- /dev/null +++ b/project_share/models/project_project.py @@ -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 diff --git a/project_share/models/project_task.py b/project_share/models/project_task.py new file mode 100644 index 0000000000..19423747e9 --- /dev/null +++ b/project_share/models/project_task.py @@ -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 diff --git a/project_share/pyproject.toml b/project_share/pyproject.toml new file mode 100644 index 0000000000..4231d0cccb --- /dev/null +++ b/project_share/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/project_share/readme/CONTRIBUTORS.md b/project_share/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..164b6bea97 --- /dev/null +++ b/project_share/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- [Dixmit](https://www.dixmit.com) + - Enric Tobella \ No newline at end of file diff --git a/project_share/readme/DESCRIPTION.md b/project_share/readme/DESCRIPTION.md new file mode 100644 index 0000000000..9ea95d1e7f --- /dev/null +++ b/project_share/readme/DESCRIPTION.md @@ -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. diff --git a/project_share/static/description/icon.png b/project_share/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/project_share/static/description/icon.png differ diff --git a/project_share/static/description/index.html b/project_share/static/description/index.html new file mode 100644 index 0000000000..680151d93d --- /dev/null +++ b/project_share/static/description/index.html @@ -0,0 +1,428 @@ + + + + + +Project Share + + + +
+

Project Share

+ + +

Beta License: AGPL-3 OCA/project Translate me on Weblate Try me on Runboat

+

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

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub 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.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Dixmit
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

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 project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/project_share/views/project_collaborator.xml b/project_share/views/project_collaborator.xml new file mode 100644 index 0000000000..8d6c6997ab --- /dev/null +++ b/project_share/views/project_collaborator.xml @@ -0,0 +1,36 @@ + + + + + + project.collaborator + + + + + + + + + + + + project.collaborator + + + + + + + + +