mirror of https://github.com/OCA/social.git
[FIX][IMP] Avoid Error Message: "A follower must be either a partner or a channel...". Show team name on activities in the chatter. Rename field string "test field"
parent
842b2abacf
commit
8650155748
|
@ -25,5 +25,6 @@
|
||||||
|
|
||||||
'qweb': [
|
'qweb': [
|
||||||
'static/src/xml/systray.xml',
|
'static/src/xml/systray.xml',
|
||||||
|
'static/src/xml/activity.xml',
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,3 +3,4 @@ from . import mail_activity
|
||||||
from . import res_users
|
from . import res_users
|
||||||
from . import mail_activity_mixin
|
from . import mail_activity_mixin
|
||||||
from . import calendar_event
|
from . import calendar_event
|
||||||
|
from . import mail_thread
|
||||||
|
|
|
@ -38,7 +38,7 @@ class MailActivity(models.Model):
|
||||||
if self.team_id and self.user_id in self.team_id.member_ids:
|
if self.team_id and self.user_id in self.team_id.member_ids:
|
||||||
return res
|
return res
|
||||||
self.team_id = self.with_context(
|
self.team_id = self.with_context(
|
||||||
default_res_model=self.res_model_id.id).\
|
default_res_model=self.res_model_id.id). \
|
||||||
_get_default_team_id(user_id=self.user_id.id)
|
_get_default_team_id(user_id=self.user_id.id)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
@ -71,3 +71,43 @@ class MailActivity(models.Model):
|
||||||
res = super().action_create_calendar_event()
|
res = super().action_create_calendar_event()
|
||||||
res['context']['default_team_id'] = self.team_id.id or False
|
res['context']['default_team_id'] = self.team_id.id or False
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def create(self, vals):
|
||||||
|
activity_user = super().create(vals)
|
||||||
|
if activity_user.team_id and not activity_user.user_id and \
|
||||||
|
activity_user.date_deadline <= fields.Date.today():
|
||||||
|
for partner_id in activity_user.team_id.mapped("member_ids.partner_id.id"):
|
||||||
|
self.env['bus.bus'].sendone(
|
||||||
|
(self._cr.dbname, 'res.partner', partner_id),
|
||||||
|
{'type': 'activity_updated', 'activity_created': True}
|
||||||
|
)
|
||||||
|
return activity_user
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
def write(self, values):
|
||||||
|
self._check_access('write')
|
||||||
|
if values.get('team_id'):
|
||||||
|
pre_responsibles = {
|
||||||
|
activity: activity.team_id.mapped("member_ids.partner_id")
|
||||||
|
for activity in self
|
||||||
|
}
|
||||||
|
res = super(MailActivity, self.sudo()).write(values)
|
||||||
|
|
||||||
|
if values.get('team_id'):
|
||||||
|
today = fields.Date.today()
|
||||||
|
for activity in self:
|
||||||
|
if activity.date_deadline <= today:
|
||||||
|
for partner in activity.team_id.member_ids.mapped("partner_id"):
|
||||||
|
self.env['bus.bus'].sendone(
|
||||||
|
(self._cr.dbname, 'res.partner', partner.id),
|
||||||
|
{'type': 'activity_updated', 'activity_created': True}
|
||||||
|
)
|
||||||
|
for activity in pre_responsibles:
|
||||||
|
if activity.date_deadline <= today:
|
||||||
|
for partner in pre_responsibles[activity]:
|
||||||
|
self.env['bus.bus'].sendone(
|
||||||
|
(self._cr.dbname, 'res.partner', partner.id),
|
||||||
|
{'type': 'activity_updated', 'activity_deleted': True}
|
||||||
|
)
|
||||||
|
return res
|
||||||
|
|
|
@ -7,7 +7,7 @@ class MailActivityMixin(models.AbstractModel):
|
||||||
_inherit = 'mail.activity.mixin'
|
_inherit = 'mail.activity.mixin'
|
||||||
|
|
||||||
activity_team_user_ids = fields.Many2many(
|
activity_team_user_ids = fields.Many2many(
|
||||||
comodel_name='res.users', string='test field',
|
comodel_name='res.users', string='Responsible Members',
|
||||||
compute="_compute_activity_team_user_ids",
|
compute="_compute_activity_team_user_ids",
|
||||||
search="_search_activity_team_user_ids",
|
search="_search_activity_team_user_ids",
|
||||||
)
|
)
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
# Copyright 2020 sewisoft, guenter.selbert
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
|
from odoo import api, models
|
||||||
|
|
||||||
|
|
||||||
|
class MailThread(models.AbstractModel):
|
||||||
|
_inherit = 'mail.thread'
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
def message_subscribe(self, partner_ids=None, channel_ids=None, subtype_ids=None,
|
||||||
|
force=True):
|
||||||
|
""" filter none """
|
||||||
|
if partner_ids:
|
||||||
|
partner_ids = [pid for pid in partner_ids if pid]
|
||||||
|
return super().message_subscribe(
|
||||||
|
partner_ids=partner_ids,
|
||||||
|
channel_ids=channel_ids,
|
||||||
|
subtype_ids=subtype_ids,
|
||||||
|
force=force
|
||||||
|
)
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<templates xml:space="preserve">
|
||||||
|
|
||||||
|
<t t-extend="mail.activity_items">
|
||||||
|
<t t-jquery="t[t-esc='activity.user_id[1]']" t-operation="after">
|
||||||
|
<t t-if="activity.team_id and activity.user_id"> / </t>
|
||||||
|
<t t-if="activity.team_id" t-esc="activity.team_id[1]"/>
|
||||||
|
</t>
|
||||||
|
</t>
|
||||||
|
|
||||||
|
</templates>
|
Loading…
Reference in New Issue