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
43 changes: 21 additions & 22 deletions mail_activity_team/README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
.. 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
==================
Expand All @@ -17,7 +13,7 @@ Mail Activity Team
.. |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
.. |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%2Fmail-lightgray.png?logo=github
Expand Down Expand Up @@ -56,6 +52,9 @@ Teams.
When you create a new activity the application will propose the user's
assigned team.

When creating activity plans, instead of assigning an activity to a
user, there is also the option to assign it to a team instead.

You can report on the activities assigned to a team going to *Dashboards
/ Activities*, and then filter by a specific team or group by teams.

Expand All @@ -81,35 +80,35 @@ Authors
Contributors
------------

- `ForgeFlow <https://www.forgeflow.com>`__:
- `ForgeFlow <https://www.forgeflow.com>`__:

- Jordi Ballester Alomar (jordi.ballester@forgeflow.com)
- Miquel Raïch (miquel.raich@forgeflow.com)
- Bernat Puig Font (bernat.puig@forgeflow.com)
- Jordi Ballester Alomar (jordi.ballester@forgeflow.com)
- Miquel Raïch (miquel.raich@forgeflow.com)
- Bernat Puig Font (bernat.puig@forgeflow.com)

- Pedro Gonzalez (pedro.gonzalez@pesol.es)
- `Tecnativa <https://www.tecnativa.com>`__:
- Pedro Gonzalez (pedro.gonzalez@pesol.es)
- `Tecnativa <https://www.tecnativa.com>`__:

- David Vidal
- David Vidal

- `Dynapps <https://www.dynapps.eu>`__:
- `Dynapps <https://www.dynapps.eu>`__:

- Raf Ven
- Raf Ven

- [Trobz] (https://trobz.com):
- [Trobz] (https://trobz.com):

- Son Ho sonhd@trobz.com
- Son Ho sonhd@trobz.com

- [Camptocamp] (https://camptocamp.com):
- [Camptocamp] (https://camptocamp.com):

- Vincent Van Rossem vincent.vanrossem@camptocamp.com
- Italo Lopes italo.lopes@camptocamp.com
- Vincent Van Rossem vincent.vanrossem@camptocamp.com
- Italo Lopes italo.lopes@camptocamp.com

- `CorporateHub <https://corporatehub.eu/>`__
- `CorporateHub <https://corporatehub.eu/>`__

- Alexey Pelykh alexey.pelykh@corphub.eu
- Alexey Pelykh alexey.pelykh@corphub.eu

- Stefan Rijnhart (stefan@opener.amsterdam)
- Stefan Rijnhart (stefan@opener.amsterdam)

Other credits
-------------
Expand Down
2 changes: 2 additions & 0 deletions mail_activity_team/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
"security/mail_activity_team_security.xml",
"wizard/mail_activity_schedule.xml",
"views/ir_actions_server_views.xml",
"views/mail_activity_plan_template_views.xml",
"views/mail_activity_plan_views.xml",
"views/mail_activity_type.xml",
"views/mail_activity_team_views.xml",
"views/mail_activity_views.xml",
Expand Down
5 changes: 3 additions & 2 deletions mail_activity_team/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from . import ir_actions_server
from . import mail_activity_team
from . import mail_activity_team # Has to load early
from . import mail_activity
from . import mail_activity_mixin
from . import res_users
from . import mail_activity_plan_template
from . import mail_activity_type
from . import res_users
7 changes: 7 additions & 0 deletions mail_activity_team/models/mail_activity_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ def activity_schedule(
user-team missmatch. We can hook onto `act_values` dict as it's passed
to the create activity method.
"""
# Pick up some defaults from mail.activity.schedule
for field in ("team_id", "team_user_id", "user_id"):
if self.env.context.get(f"schedule_default_{field}") and not act_values.get(
field
):
act_values[field] = self.env.context[f"schedule_default_{field}"]

Comment on lines +48 to +53
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the schedule_default_team_id be selectable here when Assignemnt is set to "ask at launch":

image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That could be a future addition, but it is out of scope for us at this point.

if self.env.context.get("force_activity_team"):
act_values["team_id"] = self.env.context["force_activity_team"].id
if "team_id" not in act_values:
Expand Down
95 changes: 95 additions & 0 deletions mail_activity_team/models/mail_activity_plan_template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
from odoo import api, fields, models
from odoo.exceptions import ValidationError


class MailActivityPlanTemplate(models.Model):
_inherit = "mail.activity.plan.template"

activity_team_user_id = fields.Many2one(
comodel_name="res.users",
compute="_compute_activity_team_user_id",
readonly=False,
help="The team member that the activity will be assigned to specifically",
store=True,
string="Team user",
)
activity_team_id = fields.Many2one(
comodel_name="mail.activity.team",
compute="_compute_activity_team_id",
ondelete="restrict",
readonly=False,
store=True,
string="Team assigned to",
)
activity_team_required = fields.Boolean(
compute="_compute_activity_team_required",
help="Indicate if this plan template must have an activity team",
)
# Add compute method to existing field
responsible_id = fields.Many2one(
compute="_compute_responsible_id",
readonly=False,
store=True,
)
responsible_type = fields.Selection(
ondelete={"team": "set default"},
selection_add=[("team", "Team")],
)

@api.depends("responsible_type")
def _compute_activity_team_required(self):
"""Hook to override requiredness of activity team"""
for template in self:
template.activity_team_required = template.responsible_type == "team"

@api.depends("activity_team_id", "responsible_type")
def _compute_activity_team_user_id(self):
"""Ensure consistency between the activity team and the team user"""
for template in self:
user = template.activity_team_user_id
if template.activity_team_required:
team = template.activity_team_id
if team:
if not user or user not in team.member_ids:
if team.user_id:
template.activity_team_user_id = team.user_id
elif len(team.member_ids) == 1:
template.activity_team_user_id = team.member_ids
elif user:
template.activity_team_user_id = False
elif user:
template.activity_team_user_id = False
elif user:
template.activity_team_user_id = False

@api.depends("activity_type_id", "responsible_type")
def _compute_activity_team_id(self):
"""Assign the default team from the activity type"""
for template in self:
if template.activity_team_required:
if template.activity_type_id.default_team_id:
template.activity_team_id = (
template.activity_type_id.default_team_id
)
elif template.activity_team_id:
template.activity_team_id = False

@api.depends("responsible_type")
def _compute_responsible_id(self):
"""Wipe responsible if field is not visible (c.q. allowed)"""
for template in self:
if template.activity_team_required and template.responsible_id:
template.responsible_id = False

@api.constrains("responsible_type", "activity_team_id")
def _check_activity_team(self):
for template in self:
if template.activity_team_required and not template.activity_team_id:
raise ValidationError(self.env._("Please enter an activity team."))

def _determine_responsible(self, on_demand_responsible, applied_on_record):
# Avoid signalling an error for a 'team' template without a user.
self.ensure_one()
if self.activity_team_required:
return {"error": False}
return super()._determine_responsible(on_demand_responsible, applied_on_record)
4 changes: 1 addition & 3 deletions mail_activity_team/models/mail_activity_team.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ def _compute_missing_activities(self):
@api.onchange("user_id")
def _onchange_user_id(self):
if self.user_id and self.user_id not in self.member_ids:
members_ids = self.member_ids.ids
members_ids.append(self.user_id.id)
self.member_ids = [(4, member) for member in members_ids]
self.member_ids += self.user_id

def assign_team_to_unassigned_activities(self):
activity_model = self.env["mail.activity"]
Expand Down
3 changes: 3 additions & 0 deletions mail_activity_team/readme/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@ Teams.
When you create a new activity the application will propose the user's
assigned team.

When creating activity plans, instead of assigning an activity to a user, there
is also the option to assign it to a team instead.

You can report on the activities assigned to a team going to *Dashboards
/ Activities*, and then filter by a specific team or group by teams.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<field
name="domain_force"
>[('team_id', 'in', user.activity_team_ids.ids)]</field>
<field name="groups" eval="[(4, ref('base.group_user'))]" />
<field name="groups" eval="[Command.link(ref('base.group_user'))]" />
<field name="perm_create" eval="False" />
<field name="perm_read" eval="False" />
<field name="perm_write" eval="True" />
Expand Down
30 changes: 13 additions & 17 deletions mail_activity_team/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<title>README.rst</title>
<title>Mail Activity Team</title>
<style type="text/css">

/*
Expand Down Expand Up @@ -360,21 +360,16 @@
</style>
</head>
<body>
<div class="document">
<div class="document" id="mail-activity-team">
<h1 class="title">Mail Activity Team</h1>


<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
</a>
<div class="section" id="mail-activity-team">
<h1>Mail Activity Team</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:51672fdadfaeec24c2ecce86ab4698c99dfcc197c6f803ab4281af9248dd1c0d
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/mail/tree/18.0/mail_activity_team"><img alt="OCA/mail" src="https://img.shields.io/badge/github-OCA%2Fmail-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/mail-18-0/mail-18-0-mail_activity_team"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/mail&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/mail/tree/18.0/mail_activity_team"><img alt="OCA/mail" src="https://img.shields.io/badge/github-OCA%2Fmail-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/mail-18-0/mail-18-0-mail_activity_team"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/mail&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module adds the possibility to assign teams to activities.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
Expand All @@ -391,7 +386,7 @@ <h1>Mail Activity Team</h1>
</ul>
</div>
<div class="section" id="usage">
<h2><a class="toc-backref" href="#toc-entry-1">Usage</a></h2>
<h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
<p>To set up new teams:</p>
<ol class="arabic simple">
<li>Go to <em>Settings / Activate developer mode</em></li>
Expand All @@ -404,28 +399,30 @@ <h2><a class="toc-backref" href="#toc-entry-1">Usage</a></h2>
Teams.</p>
<p>When you create a new activity the application will propose the user’s
assigned team.</p>
<p>When creating activity plans, instead of assigning an activity to a
user, there is also the option to assign it to a team instead.</p>
<p>You can report on the activities assigned to a team going to <em>Dashboards
/ Activities</em>, and then filter by a specific team or group by teams.</p>
</div>
<div class="section" id="bug-tracker">
<h2><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h2>
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/mail/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/mail/issues/new?body=module:%20mail_activity_team%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h2><a class="toc-backref" href="#toc-entry-3">Credits</a></h2>
<h1><a class="toc-backref" href="#toc-entry-3">Credits</a></h1>
<div class="section" id="authors">
<h3><a class="toc-backref" href="#toc-entry-4">Authors</a></h3>
<h2><a class="toc-backref" href="#toc-entry-4">Authors</a></h2>
<ul class="simple">
<li>ForgeFlow</li>
<li>Sodexis</li>
</ul>
</div>
<div class="section" id="contributors">
<h3><a class="toc-backref" href="#toc-entry-5">Contributors</a></h3>
<h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
<ul class="simple">
<li><a class="reference external" href="https://www.forgeflow.com">ForgeFlow</a>:<ul>
<li>Jordi Ballester Alomar (<a class="reference external" href="mailto:jordi.ballester&#64;forgeflow.com">jordi.ballester&#64;forgeflow.com</a>)</li>
Expand Down Expand Up @@ -459,12 +456,12 @@ <h3><a class="toc-backref" href="#toc-entry-5">Contributors</a></h3>
</ul>
</div>
<div class="section" id="other-credits">
<h3><a class="toc-backref" href="#toc-entry-6">Other credits</a></h3>
<h2><a class="toc-backref" href="#toc-entry-6">Other credits</a></h2>
<p>The migration of this module from 16.0 to 17.0 was financially supported
by Camptocamp</p>
</div>
<div class="section" id="maintainers">
<h3><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h3>
<h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
Expand All @@ -477,6 +474,5 @@ <h3><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h3>
</div>
</div>
</div>
</div>
</body>
</html>
Loading