diff --git a/odoo_advanced_chatter/__init__.py b/odoo_advanced_chatter/__init__.py index b13e3fa07..4e13df5a7 100644 --- a/odoo_advanced_chatter/__init__.py +++ b/odoo_advanced_chatter/__init__.py @@ -20,3 +20,4 @@ # ############################################################################# from . import models +from . import wizard diff --git a/odoo_advanced_chatter/__manifest__.py b/odoo_advanced_chatter/__manifest__.py index db4bc8290..88ac908e2 100644 --- a/odoo_advanced_chatter/__manifest__.py +++ b/odoo_advanced_chatter/__manifest__.py @@ -21,13 +21,13 @@ ############################################################################# { 'name': 'Odoo Advanced Chatter', - 'version': '17.0.1.0.0', + 'version': '17.0.2.0.0', 'category': 'Discuss', 'summary': 'Schedule Log note and Send Message in Chatter', 'description': """We have the capability to schedule log notes and send - messages within Chatter.Additionally, followers can be - managed both from the followers list - and directly within the Schedule form.""", + messages within Chatter.Additionally, followers can be managed both from + the followers list and directly within the Schedule form. We can manage the + users in the reply-to options.""", 'author': 'Cybrosys Techno Solutions', 'company': 'Cybrosys Techno Solutions', 'maintainer': 'Cybrosys Techno Solutions', @@ -37,6 +37,7 @@ 'security/ir.model.access.csv', 'data/ir_cron_data.xml', 'views/schedule_log_views.xml', + 'wizard/mail_wizard_recipients_views.xml' ], "assets": { "web.assets_backend": @@ -45,6 +46,8 @@ 'odoo_advanced_chatter/static/src/js/schedule_mail.js', 'odoo_advanced_chatter/static/src/xml/followers_check.xml', 'odoo_advanced_chatter/static/src/js/recipient_list.js', + 'odoo_advanced_chatter/static/src/xml/chatter.xml', + 'odoo_advanced_chatter/static/src/js/chatter.js' ] }, 'images': ['static/description/banner.jpg'], diff --git a/odoo_advanced_chatter/doc/RELEASE_NOTES.md b/odoo_advanced_chatter/doc/RELEASE_NOTES.md index 45af27afa..dc389baa2 100644 --- a/odoo_advanced_chatter/doc/RELEASE_NOTES.md +++ b/odoo_advanced_chatter/doc/RELEASE_NOTES.md @@ -4,3 +4,8 @@ #### Version 17.0.1.0.0 #### ADD - Initial Commit Odoo Advanced Chatter + +#### 19.06.2024 +#### Version 17.0.2.0.0 +#### UPDATE +- UPDATE diff --git a/odoo_advanced_chatter/models/__init__.py b/odoo_advanced_chatter/models/__init__.py index 418a18b36..4c20d7456 100644 --- a/odoo_advanced_chatter/models/__init__.py +++ b/odoo_advanced_chatter/models/__init__.py @@ -19,4 +19,5 @@ # If not, see . # ############################################################################# +from . import mail_thread from . import schedule_log diff --git a/odoo_advanced_chatter/models/mail_thread.py b/odoo_advanced_chatter/models/mail_thread.py new file mode 100644 index 000000000..044dde7b4 --- /dev/null +++ b/odoo_advanced_chatter/models/mail_thread.py @@ -0,0 +1,200 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Cybrosys Techno Solutions() +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################# +from odoo import api, models, _, tools +from markupsafe import Markup, escape + +import logging + +_logger = logging.getLogger(__name__) + + +class Message(models.AbstractModel): + _inherit = "mail.thread" + + @api.returns('mail.message', lambda value: value.id) + def message_post(self, *, + body='', subject=None, message_type='notification', + email_from=None, author_id=None, parent_id=False, + subtype_xmlid=None, subtype_id=False, partner_ids=None, + attachments=None, attachment_ids=None, body_is_html=False, + **kwargs): + """ Post a new message in an existing thread, returning the new mail.message. + + :param str|Markup body: body of the message, str content will be escaped, Markup + for html body + :param str subject: subject of the message + :param str message_type: see mail_message.message_type field. Can be anything but + user_notification, reserved for message_notify + :param str email_from: from address of the author. See ``_message_compute_author`` + that uses it to make email_from / author_id coherent; + :param int author_id: optional ID of partner record being the author. See + ``_message_compute_author`` that uses it to make email_from / author_id coherent; + :param int parent_id: handle thread formation + :param str subtype_xmlid: optional xml id of a mail.message.subtype to + fetch, will force value of subtype_id; + :param int subtype_id: subtype_id of the message, used mainly for followers + notification mechanism; + :param list(int) partner_ids: partner_ids to notify in addition to partners + computed based on subtype / followers matching; + :param list(tuple(str,str), tuple(str,str, dict)) attachments : list of attachment + tuples in the form ``(name,content)`` or ``(name,content, info)`` where content + is NOT base64 encoded; + :param list attachment_ids: list of existing attachments to link to this message + Should not be a list of commands. Attachment records attached to mail + composer will be attached to the related document. + :param bool body_is_html: indicates body should be threated as HTML even if str + to be used only for RPC calls + + Extra keyword arguments will be used either + * as default column values for the new mail.message record if they match + mail.message fields; + * propagated to notification methods if not; + + :return record: newly create mail.message + """ + self.ensure_one() + self._raise_for_invalid_parameters( + set(kwargs.keys()), + forbidden_names={'model', 'res_id', 'subtype'} + ) + if self._name == 'mail.thread' or not self.id: + raise ValueError( + _("Posting a message should be done on a business document. Use message_notify to send a notification to an user.")) + if message_type == 'user_notification': + raise ValueError( + _("Use message_notify to send a notification to an user.")) + if attachments: + # attachments should be a list (or tuples) of 3-elements list (or tuple) + format_error = not tools.is_list_of(attachments, + list) and not tools.is_list_of( + attachments, tuple) + if not format_error: + format_error = not all( + len(attachment) in {2, 3} for attachment in attachments) + if format_error: + raise ValueError( + _('Posting a message should receive attachments as a list of list or tuples (received %(aids)s)', + aids=repr(attachment_ids), + ) + ) + if attachment_ids and not tools.is_list_of(attachment_ids, int): + raise ValueError( + _('Posting a message should receive attachments records as a list of IDs (received %(aids)s)', + aids=repr(attachment_ids), + ) + ) + attachment_ids = list(attachment_ids or []) + if partner_ids and not tools.is_list_of(partner_ids, int): + raise ValueError( + _('Posting a message should receive partners as a list of IDs (received %(pids)s)', + pids=repr(partner_ids), + ) + ) + partner_ids = list(partner_ids or []) + msg_kwargs = {key: val for key, val in kwargs.items() + if key in self.env['mail.message']._fields} + notif_kwargs = {key: val for key, val in kwargs.items() + if key not in msg_kwargs} + self = self._fallback_lang() + guest = self.env['mail.guest']._get_guest_from_context() + if self.env.user._is_public() and guest: + author_guest_id = guest.id + author_id, email_from = False, False + else: + author_guest_id = False + author_id, email_from = self._message_compute_author(author_id, + email_from, + raise_on_email=True) + if subtype_xmlid: + subtype_id = self.env['ir.model.data']._xmlid_to_res_id( + subtype_xmlid) + if not subtype_id: + subtype_id = self.env['ir.model.data']._xmlid_to_res_id( + 'mail.mt_note') + if self._context.get('mail_post_autofollow') and partner_ids: + self.message_subscribe(partner_ids=list(partner_ids)) + msg_values = dict(msg_kwargs) + if 'email_add_signature' not in msg_values: + msg_values['email_add_signature'] = True + if not msg_values.get('record_name'): + # use sudo as record access is not always granted (notably when replying + # a notification) -> final check is done at message creation level + msg_values['record_name'] = self.sudo().display_name + if body_is_html and self.user_has_groups("base.group_user"): + _logger.warning( + "Posting HTML message using body_is_html=True, use a Markup object instead (user: %s)", + self.env.user.id) + body = Markup(body) + msg_values.update({ + # author + 'author_id': author_id, + 'author_guest_id': author_guest_id, + 'email_from': email_from, + # document + 'model': self._name, + 'res_id': self.id, + # content + 'body': escape(body), # escape if text, keep if markup + 'message_type': message_type, + 'parent_id': self._message_compute_parent_id(parent_id), + 'subject': subject or False, + 'subtype_id': subtype_id, + # recipients + 'partner_ids': partner_ids, + }) + reply_to_id = self.env['ir.config_parameter'].get_param('reply_to') + author1 = self.env['res.users'].browse(int(reply_to_id)) + email_from1 = author1.email_formatted + if 'record_alias_domain_id' not in msg_values: + msg_values['record_alias_domain_id'] = \ + self.sudo()._mail_get_alias_domains( + default_company=self.env.company)[self.id].id + if 'record_company_id' not in msg_values: + msg_values['record_company_id'] = \ + self._mail_get_companies(default=self.env.company)[self.id].id + if 'reply_to' not in msg_values: + if author1 == self.env.user.id: + msg_values['reply_to'] = \ + self._notify_get_reply_to(default=email_from)[self.id] + else: + msg_values['reply_to'] = \ + self._notify_get_reply_to(default=email_from1)[self.id] + msg_values.update( + self._process_attachments_for_post(attachments, attachment_ids, + msg_values) + ) + new_message = self._message_create([msg_values]) + author_subscribe = (not self._context.get('mail_create_nosubscribe') and + msg_values['message_type'] != 'notification') + if author_subscribe: + real_author_id = False + if self.env.user.active: + real_author_id = self.env.user.partner_id.id + elif msg_values['author_id']: + author = self.env['res.partner'].browse(msg_values['author_id']) + if author.active: + real_author_id = author.id + if real_author_id: + self._message_subscribe(partner_ids=[real_author_id]) + self._message_post_after_hook(new_message, msg_values) + self._notify_thread(new_message, msg_values, **notif_kwargs) + return new_message diff --git a/odoo_advanced_chatter/models/schedule_log.py b/odoo_advanced_chatter/models/schedule_log.py index 253ccc702..53b801afe 100644 --- a/odoo_advanced_chatter/models/schedule_log.py +++ b/odoo_advanced_chatter/models/schedule_log.py @@ -19,6 +19,7 @@ # If not, see . # ############################################################################# +from email.utils import formataddr from odoo import models, fields import datetime @@ -74,7 +75,7 @@ class ScheduleLog(models.Model): body=self.body, attachment_ids=self.attachment_ids.ids, message_type='comment', - subtype_xmlid='mail.mt_comment' + subtype_xmlid='mail.mt_comment', ) for mail in message.mail_ids: mail.send() @@ -91,6 +92,7 @@ class ScheduleLog(models.Model): body=self.body, partner_ids=partner_ids, attachment_ids=self.attachment_ids.ids, + reply_to=formataddr((self.create_uid.partner_id.name, 'email.from.1@test.example.com')) ) message.notification_ids = [fields.Command.clear()] diff --git a/odoo_advanced_chatter/security/ir.model.access.csv b/odoo_advanced_chatter/security/ir.model.access.csv index be6bd0bfe..fb297d87d 100644 --- a/odoo_advanced_chatter/security/ir.model.access.csv +++ b/odoo_advanced_chatter/security/ir.model.access.csv @@ -1,2 +1,3 @@ id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink access_schedule_log,access_schedule_log,model_schedule_log,base.group_user,1,1,1,1 +access_mail_wizard_recipient,access_mail_wizard_recipient,model_mail_wizard_recipient,base.group_user,1,1,1,1 diff --git a/odoo_advanced_chatter/static/description/assets/screenshots/10.png b/odoo_advanced_chatter/static/description/assets/screenshots/10.png new file mode 100644 index 000000000..c78ac8766 Binary files /dev/null and b/odoo_advanced_chatter/static/description/assets/screenshots/10.png differ diff --git a/odoo_advanced_chatter/static/description/assets/screenshots/11.png b/odoo_advanced_chatter/static/description/assets/screenshots/11.png new file mode 100644 index 000000000..d73dcf4d2 Binary files /dev/null and b/odoo_advanced_chatter/static/description/assets/screenshots/11.png differ diff --git a/odoo_advanced_chatter/static/description/assets/screenshots/12.png b/odoo_advanced_chatter/static/description/assets/screenshots/12.png new file mode 100644 index 000000000..ea7935e9e Binary files /dev/null and b/odoo_advanced_chatter/static/description/assets/screenshots/12.png differ diff --git a/odoo_advanced_chatter/static/description/assets/screenshots/13.png b/odoo_advanced_chatter/static/description/assets/screenshots/13.png new file mode 100644 index 000000000..53cdaefe8 Binary files /dev/null and b/odoo_advanced_chatter/static/description/assets/screenshots/13.png differ diff --git a/odoo_advanced_chatter/static/description/assets/screenshots/14.png b/odoo_advanced_chatter/static/description/assets/screenshots/14.png new file mode 100644 index 000000000..172caae9a Binary files /dev/null and b/odoo_advanced_chatter/static/description/assets/screenshots/14.png differ diff --git a/odoo_advanced_chatter/static/description/assets/screenshots/15.png b/odoo_advanced_chatter/static/description/assets/screenshots/15.png new file mode 100644 index 000000000..2c7f0d6fc Binary files /dev/null and b/odoo_advanced_chatter/static/description/assets/screenshots/15.png differ diff --git a/odoo_advanced_chatter/static/description/assets/screenshots/16.png b/odoo_advanced_chatter/static/description/assets/screenshots/16.png new file mode 100644 index 000000000..585d5fd70 Binary files /dev/null and b/odoo_advanced_chatter/static/description/assets/screenshots/16.png differ diff --git a/odoo_advanced_chatter/static/description/assets/screenshots/17.png b/odoo_advanced_chatter/static/description/assets/screenshots/17.png new file mode 100644 index 000000000..d83d91580 Binary files /dev/null and b/odoo_advanced_chatter/static/description/assets/screenshots/17.png differ diff --git a/odoo_advanced_chatter/static/description/assets/screenshots/18.png b/odoo_advanced_chatter/static/description/assets/screenshots/18.png new file mode 100644 index 000000000..3be628150 Binary files /dev/null and b/odoo_advanced_chatter/static/description/assets/screenshots/18.png differ diff --git a/odoo_advanced_chatter/static/description/assets/screenshots/hero-v17.gif b/odoo_advanced_chatter/static/description/assets/screenshots/hero-v17.gif index 95420cffc..1fa6e6bdf 100644 Binary files a/odoo_advanced_chatter/static/description/assets/screenshots/hero-v17.gif and b/odoo_advanced_chatter/static/description/assets/screenshots/hero-v17.gif differ diff --git a/odoo_advanced_chatter/static/description/index.html b/odoo_advanced_chatter/static/description/index.html index c18570a35..907c75e27 100644 --- a/odoo_advanced_chatter/static/description/index.html +++ b/odoo_advanced_chatter/static/description/index.html @@ -110,30 +110,28 @@ -
-
+
-
- -
-
-

+

+
+

- Manage Followers.

-

Recipients - can be managed seamlessly from the Followers - list - when sending messages using this module. -

-
+ Manage Followers.

+

Recipients + can be managed seamlessly from the Followers list + when sending messages using this module. +

-
+
+
+ +
+ +
+
+

+ To manage the reply-to options, create an + icon inside Chatter.

+
+
+
+
+
+ +
+ +
+
+ +
+
+

+ A wizard is opened where we can choose the + user to whom the reply is to be sent.

+
+
+
+
+
+ +
+ +
+
+

+ We can send the message

+
+
+
+
+
+
+ +
+
+

+ Go to Settings -> Technical -> Messages. + Here, you can view the messages you have + sent. In the reply-to options, you will see + the user we specified.

+
+
+
+
+
+
+ +
+
+ +
+
+ +
+
+

+ We can the same corresponding changes in the Mail details also.

+
+
+
diff --git a/odoo_advanced_chatter/static/src/js/chatter.js b/odoo_advanced_chatter/static/src/js/chatter.js new file mode 100644 index 000000000..3ff8b55f0 --- /dev/null +++ b/odoo_advanced_chatter/static/src/js/chatter.js @@ -0,0 +1,27 @@ +/** @odoo-module **/ +import { Chatter } from "@mail/core/web/chatter"; +import { patch } from "@web/core/utils/patch"; +import { _t } from "@web/core/l10n/translation"; +//patch the class ChatterContainer to added the click function +patch(Chatter.prototype ,{ + setup() { + super.setup(); + }, + replyTo(){ + //-----On clicking thr reply to icon a wizard is opened to select the recipient + const action = { + type: "ir.actions.act_window", + res_model: "mail.wizard.recipient", + view_mode: "form", + views: [[false, "form"]], + name: _t("Reply To"), + target: "new", + context: { + default_model: this.props.threadModel, + default_model_reference: this.props.threadId, + default_partner_id:this.env.model.user.userId, + }, + } + this.action.doAction(action, {}) + } +}); diff --git a/odoo_advanced_chatter/static/src/js/recipient_list.js b/odoo_advanced_chatter/static/src/js/recipient_list.js index 39598858c..b4297b997 100644 --- a/odoo_advanced_chatter/static/src/js/recipient_list.js +++ b/odoo_advanced_chatter/static/src/js/recipient_list.js @@ -11,6 +11,7 @@ patch(FollowerList.prototype, { }); }, async check(ev, follower){ + //-----To include the newly selected followers into recipients list var index = this.state.id.indexOf(follower.partner.id) if (this.state.id.includes(follower.partner.id)){ this.state.id.splice(index, 1) @@ -20,4 +21,4 @@ patch(FollowerList.prototype, { } this.threadService.check = this.state.id } -}) \ No newline at end of file +}) diff --git a/odoo_advanced_chatter/static/src/js/schedule_mail.js b/odoo_advanced_chatter/static/src/js/schedule_mail.js index b5e909a4e..2a86d6be3 100644 --- a/odoo_advanced_chatter/static/src/js/schedule_mail.js +++ b/odoo_advanced_chatter/static/src/js/schedule_mail.js @@ -86,5 +86,4 @@ setup() { this.clear() } } - -}) \ No newline at end of file +}) diff --git a/odoo_advanced_chatter/static/src/xml/chatter.xml b/odoo_advanced_chatter/static/src/xml/chatter.xml new file mode 100644 index 000000000..a1787ae47 --- /dev/null +++ b/odoo_advanced_chatter/static/src/xml/chatter.xml @@ -0,0 +1,15 @@ + + + + + + + + + diff --git a/odoo_advanced_chatter/static/src/xml/followers_check.xml b/odoo_advanced_chatter/static/src/xml/followers_check.xml index 3bb440d84..79e89961a 100644 --- a/odoo_advanced_chatter/static/src/xml/followers_check.xml +++ b/odoo_advanced_chatter/static/src/xml/followers_check.xml @@ -7,4 +7,4 @@ t-ref="check" value="1" t-on-click="(ev)=> this.check(ev,follower)"/> - \ No newline at end of file + diff --git a/odoo_advanced_chatter/wizard/__init__.py b/odoo_advanced_chatter/wizard/__init__.py new file mode 100644 index 000000000..148cf4a80 --- /dev/null +++ b/odoo_advanced_chatter/wizard/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Cybrosys Techno Solutions() +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################# +from . import mail_wizard_recipient diff --git a/odoo_advanced_chatter/wizard/mail_wizard_recipient.py b/odoo_advanced_chatter/wizard/mail_wizard_recipient.py new file mode 100644 index 000000000..65e8405ea --- /dev/null +++ b/odoo_advanced_chatter/wizard/mail_wizard_recipient.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Cybrosys Techno Solutions() +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################# +from odoo import models, fields + + +class AddRecipient(models.TransientModel): + """To add more recipients in the chatter""" + _name = 'mail.wizard.recipient' + _description = 'Add more Recipients' + + partner_id = fields.Many2one('res.users', string='Recipients', + help="Choose the user to whom we have to " + "sent the reply mail") + model = fields.Char(string='Related Model', help="Related Model") + model_reference = fields.Integer(string="Related Document Id", + help="Related Document Id") + + def add_recipients(self): + """On selecting the user to whom the mail is sent, the user is then + added to config parameters""" + self.env['ir.config_parameter'].set_param('reply_to', + self.partner_id.id) diff --git a/odoo_advanced_chatter/wizard/mail_wizard_recipients_views.xml b/odoo_advanced_chatter/wizard/mail_wizard_recipients_views.xml new file mode 100644 index 000000000..3048fa7b5 --- /dev/null +++ b/odoo_advanced_chatter/wizard/mail_wizard_recipients_views.xml @@ -0,0 +1,25 @@ + + + + + + Add Recipients + mail.wizard.recipient + +
+ + + + +
+
+
+
+