mirror of https://github.com/OCA/social.git
commit
4f41c102ca
|
@ -101,6 +101,11 @@ Contributors
|
||||||
|
|
||||||
- Son Ho sonhd@trobz.com
|
- Son Ho sonhd@trobz.com
|
||||||
|
|
||||||
|
- [Camptocamp] (https://camptocamp.com):
|
||||||
|
|
||||||
|
- Vincent Van Rossem vincent.vanrossem@camptocamp.com
|
||||||
|
- Italo Lopes italo.lopes@camptocamp.com
|
||||||
|
|
||||||
Other credits
|
Other credits
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
from . import models
|
from . import models
|
||||||
|
from . import wizard
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
# Copyright 2018-22 ForgeFlow S.L.
|
# Copyright 2018-22 ForgeFlow S.L.
|
||||||
# Copyright 2021 Sodexis
|
# Copyright 2021 Sodexis
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
|
|
||||||
{
|
{
|
||||||
"name": "Mail Activity Team",
|
"name": "Mail Activity Team",
|
||||||
"summary": "Add Teams to Activities",
|
"summary": "Add Teams to Activities",
|
||||||
|
@ -15,6 +16,7 @@
|
||||||
"data": [
|
"data": [
|
||||||
"security/ir.model.access.csv",
|
"security/ir.model.access.csv",
|
||||||
"security/mail_activity_team_security.xml",
|
"security/mail_activity_team_security.xml",
|
||||||
|
"wizard/mail_activity_schedule.xml",
|
||||||
"views/ir_actions_server_views.xml",
|
"views/ir_actions_server_views.xml",
|
||||||
"views/mail_activity_type.xml",
|
"views/mail_activity_type.xml",
|
||||||
"views/mail_activity_team_views.xml",
|
"views/mail_activity_team_views.xml",
|
||||||
|
@ -24,6 +26,7 @@
|
||||||
"assets": {
|
"assets": {
|
||||||
"web.assets_backend": [
|
"web.assets_backend": [
|
||||||
"mail_activity_team/static/src/components/*/*",
|
"mail_activity_team/static/src/components/*/*",
|
||||||
|
"mail_activity_team/static/src/core/*/*",
|
||||||
"mail_activity_team/static/src/models/*",
|
"mail_activity_team/static/src/models/*",
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
|
@ -20,7 +20,7 @@ class MailActivity(models.Model):
|
||||||
)
|
)
|
||||||
return self.env["mail.activity.team"].search(domain, limit=1)
|
return self.env["mail.activity.team"].search(domain, limit=1)
|
||||||
|
|
||||||
user_id = fields.Many2one(string="User", required=False)
|
user_id = fields.Many2one(string="User", required=False, default=False)
|
||||||
team_user_id = fields.Many2one(
|
team_user_id = fields.Many2one(
|
||||||
string="Team user", related="user_id", readonly=False
|
string="Team user", related="user_id", readonly=False
|
||||||
)
|
)
|
||||||
|
@ -31,6 +31,24 @@ class MailActivity(models.Model):
|
||||||
index=True,
|
index=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@api.model_create_multi
|
||||||
|
def create(self, vals_list):
|
||||||
|
# Differently from the previous odoo version,
|
||||||
|
# the create method is called from (mail.activity.mixin).activity_schedule()
|
||||||
|
# and on this method we are forcing the user_id to be the current user from
|
||||||
|
# odoo import api, fields, models the default one linked to the activity type.
|
||||||
|
# We don't want this behavior because using the team_id, we want to assign the
|
||||||
|
# activity to the whole team.
|
||||||
|
for vals in vals_list:
|
||||||
|
# we need to be sure that we are in a context where the team_id is set,
|
||||||
|
# and we don't want to use user_id
|
||||||
|
if "team_id" in vals:
|
||||||
|
# using team, we have user_id = team_user_id,
|
||||||
|
# so if we don't have a user_team_id we don't want user_id too
|
||||||
|
if "user_id" in vals and not vals.get("team_user_id", False):
|
||||||
|
del vals["user_id"]
|
||||||
|
return super().create(vals_list)
|
||||||
|
|
||||||
@api.onchange("user_id")
|
@api.onchange("user_id")
|
||||||
def _onchange_user_id(self):
|
def _onchange_user_id(self):
|
||||||
if not self.user_id or (
|
if not self.user_id or (
|
||||||
|
|
|
@ -9,3 +9,6 @@
|
||||||
- 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):
|
||||||
|
- Vincent Van Rossem <vincent.vanrossem@camptocamp.com>
|
||||||
|
- Italo Lopes <italo.lopes@camptocamp.com>
|
||||||
|
|
|
@ -8,11 +8,10 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
:Author: David Goodger (goodger@python.org)
|
:Author: David Goodger (goodger@python.org)
|
||||||
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
|
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
|
||||||
:Copyright: This stylesheet has been placed in the public domain.
|
:Copyright: This stylesheet has been placed in the public domain.
|
||||||
|
|
||||||
Default cascading style sheet for the HTML output of Docutils.
|
Default cascading style sheet for the HTML output of Docutils.
|
||||||
Despite the name, some widely supported CSS2 features are used.
|
|
||||||
|
|
||||||
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
|
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
|
||||||
customize this style sheet.
|
customize this style sheet.
|
||||||
|
@ -275,7 +274,7 @@ pre.literal-block, pre.doctest-block, pre.math, pre.code {
|
||||||
margin-left: 2em ;
|
margin-left: 2em ;
|
||||||
margin-right: 2em }
|
margin-right: 2em }
|
||||||
|
|
||||||
pre.code .ln { color: gray; } /* line numbers */
|
pre.code .ln { color: grey; } /* line numbers */
|
||||||
pre.code, code { background-color: #eeeeee }
|
pre.code, code { background-color: #eeeeee }
|
||||||
pre.code .comment, code .comment { color: #5C6576 }
|
pre.code .comment, code .comment { color: #5C6576 }
|
||||||
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
|
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
|
||||||
|
@ -301,7 +300,7 @@ span.option {
|
||||||
span.pre {
|
span.pre {
|
||||||
white-space: pre }
|
white-space: pre }
|
||||||
|
|
||||||
span.problematic, pre.problematic {
|
span.problematic {
|
||||||
color: red }
|
color: red }
|
||||||
|
|
||||||
span.section-subtitle {
|
span.section-subtitle {
|
||||||
|
@ -447,6 +446,11 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
|
||||||
<li>Son Ho <a class="reference external" href="mailto:sonhd@trobz.com">sonhd@trobz.com</a></li>
|
<li>Son Ho <a class="reference external" href="mailto:sonhd@trobz.com">sonhd@trobz.com</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
<li>[Camptocamp] (<a class="reference external" href="https://camptocamp.com">https://camptocamp.com</a>):<ul>
|
||||||
|
<li>Vincent Van Rossem <a class="reference external" href="mailto:vincent.vanrossem@camptocamp.com">vincent.vanrossem@camptocamp.com</a></li>
|
||||||
|
<li>Italo Lopes <a class="reference external" href="mailto:italo.lopes@camptocamp.com">italo.lopes@camptocamp.com</a></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="other-credits">
|
<div class="section" id="other-credits">
|
||||||
|
@ -457,9 +461,7 @@ by Camptocamp</p>
|
||||||
<div class="section" id="maintainers">
|
<div class="section" id="maintainers">
|
||||||
<h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
|
<h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
|
||||||
<p>This module is maintained by the OCA.</p>
|
<p>This module is maintained by the OCA.</p>
|
||||||
<a class="reference external image-reference" href="https://odoo-community.org">
|
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
|
||||||
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
|
|
||||||
</a>
|
|
||||||
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
|
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
|
||||||
mission is to support the collaborative development of Odoo features and
|
mission is to support the collaborative development of Odoo features and
|
||||||
promote its widespread use.</p>
|
promote its widespread use.</p>
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<templates xml:space="preserve">
|
||||||
|
|
||||||
|
<t
|
||||||
|
t-name="mail_activity_team.Activity"
|
||||||
|
t-inherit="mail.Activity"
|
||||||
|
t-inherit-mode="extension"
|
||||||
|
>
|
||||||
|
<xpath
|
||||||
|
expr="//div/div[hasclass('o-mail-Activity-sidebar')]/img"
|
||||||
|
position="attributes"
|
||||||
|
>
|
||||||
|
<attribute name="t-if">activity.user_id</attribute>
|
||||||
|
</xpath>
|
||||||
|
<xpath
|
||||||
|
expr="//div/div/div[hasclass('o-mail-Activity-info')]/span[hasclass('o-mail-Activity-user')]"
|
||||||
|
position="attributes"
|
||||||
|
>
|
||||||
|
<attribute name="t-if">activity.user_id</attribute>
|
||||||
|
</xpath>
|
||||||
|
|
||||||
|
</t>
|
||||||
|
|
||||||
|
</templates>
|
|
@ -242,10 +242,10 @@ class TestMailActivityTeam(TransactionCase):
|
||||||
self.env.ref("mail.mail_activity_data_call").default_team_id = self.team2
|
self.env.ref("mail.mail_activity_data_call").default_team_id = self.team2
|
||||||
activity = partner_record.activity_schedule(
|
activity = partner_record.activity_schedule(
|
||||||
act_type_xmlid="mail.mail_activity_data_call",
|
act_type_xmlid="mail.mail_activity_data_call",
|
||||||
user_id=self.employee2.id,
|
|
||||||
)
|
)
|
||||||
self.assertEqual(activity.team_id, self.team2)
|
self.assertEqual(activity.team_id, self.team2)
|
||||||
self.assertEqual(activity.user_id, self.employee2)
|
# As we are in a 'team activity' context, the user should not be set
|
||||||
|
self.assertEqual(activity.user_id, self.env["res.users"])
|
||||||
|
|
||||||
def test_schedule_activity_default_team_no_user(self):
|
def test_schedule_activity_default_team_no_user(self):
|
||||||
"""Correctly assign teams to auto scheduled activities. Those won't
|
"""Correctly assign teams to auto scheduled activities. Those won't
|
||||||
|
@ -257,7 +257,8 @@ class TestMailActivityTeam(TransactionCase):
|
||||||
activity_type_id=self.activity2.id,
|
activity_type_id=self.activity2.id,
|
||||||
)
|
)
|
||||||
self.assertEqual(activity.team_id, self.team2)
|
self.assertEqual(activity.team_id, self.team2)
|
||||||
self.assertEqual(activity.user_id, self.employee2)
|
# As we are in a 'team activity' context, the user should not be set
|
||||||
|
self.assertEqual(activity.user_id, self.env["res.users"])
|
||||||
|
|
||||||
def test_activity_count(self):
|
def test_activity_count(self):
|
||||||
res = (
|
res = (
|
||||||
|
@ -300,7 +301,8 @@ class TestMailActivityTeam(TransactionCase):
|
||||||
_messages, next_activities = activity._action_done()
|
_messages, next_activities = activity._action_done()
|
||||||
self.assertTrue(next_activities)
|
self.assertTrue(next_activities)
|
||||||
self.assertEqual(next_activities.team_id, self.team2)
|
self.assertEqual(next_activities.team_id, self.team2)
|
||||||
self.assertEqual(next_activities.user_id, self.employee2)
|
# As we are in a 'team activity' context, the user should not be set
|
||||||
|
self.assertEqual(next_activities.user_id, self.env["res.users"])
|
||||||
|
|
||||||
def test_schedule_activity_from_server_action(self):
|
def test_schedule_activity_from_server_action(self):
|
||||||
partner = self.env["res.partner"].create({"name": "Test Partner"})
|
partner = self.env["res.partner"].create({"name": "Test Partner"})
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
from . import mail_activity_schedule
|
|
@ -0,0 +1,71 @@
|
||||||
|
# Copyright 2024 Camptocamp SA
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
|
|
||||||
|
from odoo import api, fields, models
|
||||||
|
|
||||||
|
|
||||||
|
class MailActivitySchedule(models.TransientModel):
|
||||||
|
_inherit = "mail.activity.schedule"
|
||||||
|
|
||||||
|
activity_team_user_id = fields.Many2one(
|
||||||
|
string="Team user", related="activity_user_id", store=True, readonly=False
|
||||||
|
)
|
||||||
|
activity_team_id = fields.Many2one(
|
||||||
|
"mail.activity.team",
|
||||||
|
"Team assigned to",
|
||||||
|
compute="_compute_activity_team_id",
|
||||||
|
store=True,
|
||||||
|
readonly=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
@api.depends("activity_type_id")
|
||||||
|
def _compute_activity_team_id(self):
|
||||||
|
for scheduler in self:
|
||||||
|
if scheduler.activity_type_id.default_team_id:
|
||||||
|
scheduler.activity_team_id = scheduler.activity_type_id.default_team_id
|
||||||
|
elif not scheduler.activity_team_id:
|
||||||
|
scheduler.activity_team_id = (
|
||||||
|
self.env["mail.activity"]
|
||||||
|
.with_context(default_res_model=self.sudo().res_model_id.model)
|
||||||
|
._get_default_team_id(user_id=scheduler.activity_team_user_id.id)
|
||||||
|
)
|
||||||
|
|
||||||
|
@api.onchange("activity_team_id")
|
||||||
|
def _onchange_activity_team_id(self):
|
||||||
|
if (
|
||||||
|
self.activity_team_id
|
||||||
|
and self.activity_team_user_id not in self.activity_team_id.member_ids
|
||||||
|
):
|
||||||
|
if self.activity_team_id.user_id:
|
||||||
|
new_user_id = self.activity_team_id.user_id
|
||||||
|
elif len(self.activity_team_id.member_ids) == 1:
|
||||||
|
new_user_id = self.activity_team_id.member_ids
|
||||||
|
else:
|
||||||
|
new_user_id = self.env["res.users"]
|
||||||
|
self.activity_team_user_id = new_user_id
|
||||||
|
self.activity_user_id = new_user_id
|
||||||
|
|
||||||
|
@api.onchange("activity_team_user_id")
|
||||||
|
def _onchange_activity_team_user_id(self):
|
||||||
|
if not self.activity_team_user_id or (
|
||||||
|
self.activity_team_user_id
|
||||||
|
and self.activity_team_user_id in self.activity_team_id.member_ids
|
||||||
|
):
|
||||||
|
return
|
||||||
|
self.activity_team_id = (
|
||||||
|
self.env["mail.activity"]
|
||||||
|
.with_context(default_res_model=self.sudo().res_model_id.model)
|
||||||
|
._get_default_team_id(user_id=self.activity_team_user_id.id)
|
||||||
|
)
|
||||||
|
|
||||||
|
def _action_schedule_activities(self):
|
||||||
|
return self._get_applied_on_records().activity_schedule(
|
||||||
|
activity_type_id=self.activity_type_id.id,
|
||||||
|
automated=False,
|
||||||
|
summary=self.summary,
|
||||||
|
note=self.note,
|
||||||
|
user_id=self.activity_team_user_id.id,
|
||||||
|
team_user_id=self.activity_team_user_id.id,
|
||||||
|
team_id=self.activity_team_id.id,
|
||||||
|
date_deadline=self.date_deadline,
|
||||||
|
)
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<odoo>
|
||||||
|
|
||||||
|
<record id="mail_activity_schedule_view_form" model="ir.ui.view">
|
||||||
|
<field name="model">mail.activity.schedule</field>
|
||||||
|
<field name="inherit_id" ref="mail.mail_activity_schedule_view_form" />
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<field name="activity_user_id" position="attributes">
|
||||||
|
<attribute name="invisible">activity_team_id</attribute>
|
||||||
|
<attribute
|
||||||
|
name="required"
|
||||||
|
add="and not activity_team_id"
|
||||||
|
separator=" "
|
||||||
|
/>
|
||||||
|
</field>
|
||||||
|
<field name="activity_user_id" position="after">
|
||||||
|
<field name="res_model_id" invisible="1" />
|
||||||
|
<field
|
||||||
|
name="activity_team_user_id"
|
||||||
|
invisible="not activity_team_id"
|
||||||
|
domain="[('activity_team_ids', '=', activity_team_id)]"
|
||||||
|
/>
|
||||||
|
<field
|
||||||
|
name="activity_team_id"
|
||||||
|
options="{'no_create': True, 'no_open': True}"
|
||||||
|
domain="['|', ('res_model_ids', '=', False), ('res_model_ids', '=', res_model_id)]"
|
||||||
|
/>
|
||||||
|
</field>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</odoo>
|
Loading…
Reference in New Issue