[IMP]project_assignees:notify assignees #17
@@ -1,3 +1,4 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
from . import models
|
from . import models
|
||||||
|
from . import models
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
"name": "project_assignees",
|
"name": "project_assignees",
|
||||||
"version": "14.0.1.1.0",
|
"version": "14.0.1.2.0",
|
||||||
"author": "Elabore",
|
"author": "Elabore",
|
||||||
"website": "https://github.com/elabore-coop/project-tools",
|
"website": "https://github.com/elabore-coop/project-tools",
|
||||||
"maintainer": "Stéphan Sainléger",
|
"maintainer": "Stéphan Sainléger",
|
||||||
|
@@ -1,2 +1,3 @@
|
|||||||
|
|
||||||
from . import project_task
|
from . import project_task
|
||||||
|
from . import mail_thread
|
||||||
|
42
project_assignees/models/mail_thread.py
Normal file
42
project_assignees/models/mail_thread.py
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||||
|
|
||||||
|
from odoo import models
|
||||||
|
|
||||||
|
class MailThread(models.AbstractModel):
|
||||||
|
_inherit = 'mail.thread'
|
||||||
|
|
||||||
|
def _message_auto_subscribe_followers(self, updated_values, default_subtype_ids):
|
||||||
|
""" Overrides mail.thread._message_auto_subscribe_followers() only in a project task context.
|
||||||
|
|
||||||
|
In a project task context : user(s) to notify are the assignees (field assignee_ids not user_id)
|
||||||
|
In other context : use parent _message_auto_subscribe_followers and notify the user identify by the field user_id
|
||||||
|
|
||||||
|
Return a list tuples containing (
|
||||||
|
partner ID,
|
||||||
|
subtype IDs (or False if model-based default subtypes),
|
||||||
|
QWeb template XML ID for notification (or False is no specific
|
||||||
|
notification is required),
|
||||||
|
), aka partners and their subtype and possible notification to send
|
||||||
|
using the auto subscription mechanism linked to updated values.
|
||||||
|
|
||||||
|
:param updated_values: see ``_message_auto_subscribe``
|
||||||
|
:param default_subtype_ids: coming from ``_get_auto_subscription_subtypes``
|
||||||
|
"""
|
||||||
|
|
||||||
|
if self._name == 'project.task' :
|
||||||
|
results = []
|
||||||
|
assignee_ids = updated_values.get('assignee_ids')
|
||||||
|
if assignee_ids and len(assignee_ids) == 1 and assignee_ids[0][0] == 6:
|
||||||
|
user_ids = assignee_ids[0][-1]
|
||||||
|
users = self.env['res.users'].sudo().browse(user_ids)
|
||||||
|
if users :
|
||||||
|
for user in users :
|
||||||
|
try:
|
||||||
|
if user.active:
|
||||||
|
results.append((user.partner_id.id, default_subtype_ids, 'mail.message_user_assigned' if user != self.env.user else False))
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
return results
|
||||||
|
else:
|
||||||
|
return super()._message_auto_subscribe_followers(updated_values, default_subtype_ids)
|
@@ -5,5 +5,5 @@ from odoo import models, fields
|
|||||||
class Task(models.Model):
|
class Task(models.Model):
|
||||||
_inherit = "project.task"
|
_inherit = "project.task"
|
||||||
|
|
||||||
assignee_ids = fields.Many2many('res.users', 'assignee_ids_rel', string='Assignees')
|
assignee_ids = fields.Many2many('res.users', 'assignee_ids_rel', string='Assignees', tracking=True)
|
||||||
|
|
||||||
|
0
project_followers/__init__.py
Normal file
0
project_followers/__init__.py
Normal file
26
project_followers/__manifest__.py
Normal file
26
project_followers/__manifest__.py
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
'name': 'Project Followers',
|
||||||
|
'version': '14.0.1.0.0',
|
||||||
|
'description': 'disable partner checked by while sending a message in project task chatter',
|
||||||
|
'summary': '',
|
||||||
|
'author': '',
|
||||||
|
'website': '',
|
||||||
|
'license': 'LGPL-3',
|
||||||
|
'category': '',
|
||||||
|
'depends': [
|
||||||
|
'base','mail'
|
||||||
|
],
|
||||||
|
'data': [
|
||||||
|
''
|
||||||
|
],
|
||||||
|
'demo': [
|
||||||
|
''
|
||||||
|
],
|
||||||
|
'auto_install': False,
|
||||||
|
'application': False,
|
||||||
|
"assets": {
|
||||||
|
"web.assets_frontend": [
|
||||||
|
"project_followers/static/src/js/suggested_recipient_info_custom.js",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
}
|
@@ -0,0 +1,17 @@
|
|||||||
|
odoo.define('project_followers.suggested_recipient_info_custom', function (require) {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const SuggestedRecipientInfo = require('mail.suggested_recipient_info');
|
||||||
|
|
||||||
|
SuggestedRecipientInfo.include({
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
_computeIsSelected: function () {
|
||||||
|
// Votre code de surcharge ici
|
||||||
|
// N'oubliez pas d'appeler la fonction d'origine si nécessaire
|
||||||
|
return this.partner ? this.isSelected : false;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
Reference in New Issue
Block a user