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
12 changes: 12 additions & 0 deletions mail_activity_team_restrict/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Mail Activity Team Restrict

This module extends `mail_activity_restrict` together with `mail_activity_team`.

When `can_write_restrict` is enabled on an activity type, the base module limits edits
to the assigned user. This addon extends that rule so members of the activity `team_id`
may also edit the activity and mark it as done.

No additional configuration is introduced. The module reuses:

- `mail.activity.type.can_write_restrict` from `mail_activity_restrict`
- `mail.activity.team_id` and `mail.activity.team.member_ids` from `mail_activity_team`
94 changes: 94 additions & 0 deletions mail_activity_team_restrict/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

===========================
Mail Activity Team Restrict
===========================

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

.. |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/license-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%2Fmail-lightgray.png?logo=github
:target: https://github.com/OCA/mail/tree/19.0/mail_activity_team_restrict
:alt: OCA/mail
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/mail-19-0/mail-19-0-mail_activity_team_restrict
: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/mail&target_branch=19.0
:alt: Try me on Runboat

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

This module extends mail_activity_restrict with team support.

For activity types with "Restrict Write to Assigned User" enabled,
activity team members are also allowed to edit and complete the
activity.

No extra configuration field is added on the activity type. It reuses
the same restriction option from mail_activity_restrict and the team
membership from mail_activity_team.

**Table of contents**

.. contents::
:local:

Usage
=====

To use this module:

1. Enable "Restrict Write to Assigned User" on the activity type.
2. Assign a team on the activity.
3. Make sure users are members of that team.

Allowed users for restricted activities are:

- The assigned user.
- Members of the assigned team.

Users outside that scope cannot edit or complete the activity.

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/mail/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/mail/issues/new?body=module:%20mail_activity_team_restrict%0Aversion:%2019.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
=======

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/mail <https://github.com/OCA/mail/tree/19.0/mail_activity_team_restrict>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions mail_activity_team_restrict/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
15 changes: 15 additions & 0 deletions mail_activity_team_restrict/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "Mail Activity Team Restrict",
"version": "19.0.1.0.0",
"category": "Productivity/Mail",
"license": "AGPL-3",
"author": "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/mail",
"depends": [
"mail_activity_restrict",
"mail_activity_team",
],
"installable": True,
"application": False,
"auto_install": True,
}
1 change: 1 addition & 0 deletions mail_activity_team_restrict/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import mail_activity
37 changes: 37 additions & 0 deletions mail_activity_team_restrict/models/mail_activity.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
"""Extend restricted activities to members of the assigned team."""

from odoo import models
from odoo.exceptions import AccessError


class MailActivity(models.Model):
"""Allow team members to modify restricted activities."""

_inherit = "mail.activity"

def _get_can_write_restrict_allowed_activities(self):
"""Allow the assignee and members of the assigned team."""
return (
super()._get_can_write_restrict_allowed_activities()
| self.sudo().filtered_domain([("team_id.member_ids", "in", self.env.uid)])
)

def _make_can_write_restrict_error(self, operation: str) -> AccessError:
"""Build the access error raised for restricted team activities."""
if len(self) == 1:
return AccessError(
self.env._(
"You cannot %(operation)s this activity because only the assigned "
"user or members of the assigned team can modify activities of this"
" type.",
operation=operation,
)
)
return AccessError(
self.env._(
"You cannot %(operation)s some activities because only their assigned "
"user or members of the assigned team can modify activities of this "
"type.",
operation=operation,
)
)
3 changes: 3 additions & 0 deletions mail_activity_team_restrict/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
8 changes: 8 additions & 0 deletions mail_activity_team_restrict/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
This module extends mail_activity_restrict with team support.

For activity types with "Restrict Write to Assigned User" enabled, activity
team members are also allowed to edit and complete the activity.

No extra configuration field is added on the activity type. It reuses the
same restriction option from mail_activity_restrict and the team membership
from mail_activity_team.
11 changes: 11 additions & 0 deletions mail_activity_team_restrict/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
To use this module:

1. Enable "Restrict Write to Assigned User" on the activity type.
2. Assign a team on the activity.
3. Make sure users are members of that team.

Allowed users for restricted activities are:
- The assigned user.
- Members of the assigned team.

Users outside that scope cannot edit or complete the activity.
Loading
Loading