@ -0,0 +1,44 @@ |
|||||
|
.. image:: https://img.shields.io/badge/license-LGPL--3-green.svg |
||||
|
:target: https://www.gnu.org/licenses/lgpl-3.0-standalone.html |
||||
|
:alt: License: LGPL-3 |
||||
|
|
||||
|
Odoo Advanced Chatter |
||||
|
===================== |
||||
|
This module facilitates effortless scheduling of logs and sending messages. |
||||
|
Additionally, it streamlines recipient management by allowing easy selection from the followers list when sending messages. |
||||
|
|
||||
|
Configuration |
||||
|
============= |
||||
|
* No additional configurations needed |
||||
|
|
||||
|
Company |
||||
|
------- |
||||
|
* `Cybrosys Techno Solutions <https://cybrosys.com/>`__ |
||||
|
|
||||
|
Credits |
||||
|
------- |
||||
|
* Developer: (V17) NIHALA KP, |
||||
|
(V18) Gayathri V |
||||
|
Contact: odoo@cybrosys.com |
||||
|
|
||||
|
Contacts |
||||
|
-------- |
||||
|
* Mail Contact : odoo@cybrosys.com |
||||
|
* Website : https://cybrosys.com |
||||
|
|
||||
|
Bug Tracker |
||||
|
----------- |
||||
|
Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. |
||||
|
|
||||
|
Maintainer |
||||
|
========== |
||||
|
.. image:: https://cybrosys.com/images/logo.png |
||||
|
:target: https://cybrosys.com |
||||
|
|
||||
|
This module is maintained by Cybrosys Technologies. |
||||
|
|
||||
|
For support and more information, please visit `Our Website <https://cybrosys.com/>`__ |
||||
|
|
||||
|
Further information |
||||
|
=================== |
||||
|
HTML Description: `<static/description/index.html>`__ |
@ -0,0 +1,23 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################# |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
||||
|
# Author: Gayathri V(<https://www.cybrosys.com>) |
||||
|
# |
||||
|
# 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 <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################# |
||||
|
from . import models |
||||
|
from . import wizard |
@ -0,0 +1,58 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################# |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
||||
|
# Author: Gayathri V(<https://www.cybrosys.com>) |
||||
|
# |
||||
|
# 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 <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################# |
||||
|
{ |
||||
|
'name': 'Odoo Advanced Chatter', |
||||
|
'version': '18.0.1.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. We can manage the |
||||
|
users in the reply-to options.""", |
||||
|
'author': 'Cybrosys Techno Solutions', |
||||
|
'company': 'Cybrosys Techno Solutions', |
||||
|
'maintainer': 'Cybrosys Techno Solutions', |
||||
|
'website': "https://www.cybrosys.com", |
||||
|
'depends': ['web', 'base', 'mail'], |
||||
|
'data': [ |
||||
|
'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": |
||||
|
[ |
||||
|
'odoo_advanced_chatter/static/src/xml/schedule_log.xml', |
||||
|
'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'], |
||||
|
'license': 'LGPL-3', |
||||
|
'installable': True, |
||||
|
'auto_install': False, |
||||
|
'application': False, |
||||
|
} |
@ -0,0 +1,15 @@ |
|||||
|
<?xml version="1.0" encoding = "utf-8"?> |
||||
|
<odoo> |
||||
|
<!-- Create scheduled action for mail sending --> |
||||
|
<data noupdate="1"> |
||||
|
<record id="ir_cron_scheduler_scheduler_log" model="ir.cron"> |
||||
|
<field name="name">Schedule Log Note</field> |
||||
|
<field name="model_id" ref="model_schedule_log"/> |
||||
|
<field name="state">code</field> |
||||
|
<field name="code">model.schedule()</field> |
||||
|
<field name="user_id" ref="base.user_root"/> |
||||
|
<field name="interval_number">1</field> |
||||
|
<field name="interval_type">minutes</field> |
||||
|
</record> |
||||
|
</data> |
||||
|
</odoo> |
@ -0,0 +1,6 @@ |
|||||
|
## Module <odoo_advanced_chatter> |
||||
|
|
||||
|
#### 18.10.2024 |
||||
|
#### Version 18.0.1.0.0 |
||||
|
#### ADD |
||||
|
- Initial Commit Odoo Advanced Chatter |
@ -0,0 +1,23 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################# |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
||||
|
# Author: Gayathri V(<https://www.cybrosys.com>) |
||||
|
# |
||||
|
# 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 <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################# |
||||
|
from . import mail_thread |
||||
|
from . import schedule_log |
@ -0,0 +1,198 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################# |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
||||
|
# Author: Gayathri V(<https://www.cybrosys.com>) |
||||
|
# |
||||
|
# 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 <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################# |
||||
|
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'): |
||||
|
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), |
||||
|
'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 |
@ -0,0 +1,170 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################# |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
||||
|
# Author: Gayathri V(<https://www.cybrosys.com>) |
||||
|
# |
||||
|
# 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 <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################# |
||||
|
from email.utils import formataddr |
||||
|
|
||||
|
from odoo import models, fields |
||||
|
import datetime |
||||
|
|
||||
|
|
||||
|
class ScheduleLog(models.Model): |
||||
|
"""To schedule the log note and message inside the chatter""" |
||||
|
_name = 'schedule.log' |
||||
|
_description = "Schedule log note in chatter" |
||||
|
|
||||
|
body = fields.Html(string="Body", help="Content of the log", required="1") |
||||
|
partner_ids = fields.Many2many('res.partner', string='Recipients', |
||||
|
help='To whom the log is Mentioned') |
||||
|
time = fields.Datetime( |
||||
|
default=lambda self: fields.datetime.now().strftime( |
||||
|
'%Y-%m-%d %H:%M:%S'), |
||||
|
string="Scheduled Time", |
||||
|
help="Time at which the log is scheduled", |
||||
|
required="1") |
||||
|
attachment_ids = fields.Many2many(comodel_name='ir.attachment', |
||||
|
string="Attachments", help="Attachments") |
||||
|
is_log = fields.Boolean(string='Is Log', default=False, |
||||
|
help="To check whether log note or scheduled " |
||||
|
"messages") |
||||
|
model = fields.Char(string='Related Model', help="Related Model") |
||||
|
model_reference = fields.Integer(string="Related Document Id", |
||||
|
help="Related Document Id") |
||||
|
status = fields.Selection([('draft', "Schedule"), ('post', "Post")], |
||||
|
string='Status', default='draft', |
||||
|
help="Status of the Message") |
||||
|
|
||||
|
def action_save(self): |
||||
|
"""Display notification when messages are scheduled""" |
||||
|
if self.body: |
||||
|
self.env.registry.clear_cache() |
||||
|
current_time = fields.Datetime.now().replace(second=0) |
||||
|
scheduled_time = fields.Datetime.from_string(self.time).replace( |
||||
|
second=0) |
||||
|
time_difference = abs( |
||||
|
(current_time - scheduled_time).total_seconds()) |
||||
|
acceptable_difference = 5 |
||||
|
if time_difference <= acceptable_difference: |
||||
|
user_id = self.env.user.commercial_partner_id |
||||
|
partner_ids = self.partner_ids.ids |
||||
|
if user_id.id in self.partner_ids.ids: |
||||
|
partner_ids.remove(user_id.id) |
||||
|
model = self.env[self.model].sudo().browse( |
||||
|
self.model_reference) |
||||
|
if not self.is_log: |
||||
|
message = model.message_post( |
||||
|
author_id=self.create_uid.partner_id.id, |
||||
|
email_from=self.create_uid.partner_id.email, |
||||
|
body=self.body, |
||||
|
attachment_ids=self.attachment_ids.ids, |
||||
|
message_type='comment', |
||||
|
subtype_xmlid='mail.mt_comment', |
||||
|
) |
||||
|
for mail in message.mail_ids: |
||||
|
mail.send() |
||||
|
self.status = 'post' |
||||
|
return { |
||||
|
'type': 'ir.actions.client', |
||||
|
'tag': 'reload_context', |
||||
|
} |
||||
|
|
||||
|
else: |
||||
|
message = model.message_post( |
||||
|
author_id=self.create_uid.partner_id.id, |
||||
|
email_from=self.create_uid.partner_id.email, |
||||
|
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()] |
||||
|
message.notification_ids = [fields.Command.create({ |
||||
|
'res_partner_id': pid |
||||
|
}) for pid in partner_ids] |
||||
|
self.status = 'post' |
||||
|
return { |
||||
|
'type': 'ir.actions.client', |
||||
|
'tag': 'reload_context', |
||||
|
} |
||||
|
else: |
||||
|
return { |
||||
|
'type': 'ir.actions.client', |
||||
|
'tag': 'display_notification', |
||||
|
'params': { |
||||
|
'title': 'Title', |
||||
|
'message': "Message scheduled successfully.", |
||||
|
'sticky': True, |
||||
|
'next': {'type': 'ir.actions.act_window_close'}, |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
def schedule(self): |
||||
|
"""To schedule the log note""" |
||||
|
date = datetime.datetime.now() |
||||
|
date_sec = date.replace(second=0).strftime('%Y-%m-%d %H:%M:%S') |
||||
|
date_max = date.replace(second=59).strftime('%Y-%m-%d %H:%M:%S') |
||||
|
scheduled_lognotes = self.env['schedule.log'].search( |
||||
|
[ |
||||
|
('status', '=', 'draft'), |
||||
|
('time', '>=', date_sec), |
||||
|
('time', '<=', date_max), |
||||
|
] |
||||
|
) |
||||
|
for rec in scheduled_lognotes: |
||||
|
user_id = rec.env.user.commercial_partner_id |
||||
|
partner_ids = rec.partner_ids.ids |
||||
|
if user_id.id in rec.partner_ids.ids: |
||||
|
partner_ids.remove(user_id.id) |
||||
|
model = self.env[rec.model].sudo().browse( |
||||
|
rec.model_reference) |
||||
|
if not rec.is_log: |
||||
|
message = model.message_post( |
||||
|
author_id=rec.create_uid.partner_id.id, |
||||
|
email_from=rec.create_uid.partner_id.email, |
||||
|
body=rec.body, |
||||
|
attachment_ids=rec.attachment_ids.ids, |
||||
|
message_type='comment', |
||||
|
subtype_xmlid='mail.mt_comment' |
||||
|
) |
||||
|
for mail in message.mail_ids: |
||||
|
mail.send() |
||||
|
rec.status = 'post' |
||||
|
return { |
||||
|
'type': 'ir.actions.client', |
||||
|
'tag': 'reload', |
||||
|
} |
||||
|
else: |
||||
|
message = model.message_post( |
||||
|
author_id=rec.create_uid.partner_id.id, |
||||
|
email_from=rec.create_uid.partner_id.email, |
||||
|
body=rec.body, |
||||
|
partner_ids=partner_ids, |
||||
|
attachment_ids=rec.attachment_ids.ids, |
||||
|
) |
||||
|
message.notification_ids = [fields.Command.clear()] |
||||
|
message.notification_ids = [fields.Command.create({ |
||||
|
'res_partner_id': pid |
||||
|
}) for pid in partner_ids] |
||||
|
rec.status = 'post' |
||||
|
return { |
||||
|
'type': 'ir.actions.client', |
||||
|
'tag': 'reload_context', |
||||
|
} |
|
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 628 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 210 KiB |
After Width: | Height: | Size: 209 KiB |
After Width: | Height: | Size: 109 KiB |
After Width: | Height: | Size: 495 B |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 624 B |
After Width: | Height: | Size: 136 KiB |
After Width: | Height: | Size: 214 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 310 B |
After Width: | Height: | Size: 929 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 542 B |
After Width: | Height: | Size: 576 B |
After Width: | Height: | Size: 733 B |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 569 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 911 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 600 B |
After Width: | Height: | Size: 673 B |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 462 B |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 926 B |
After Width: | Height: | Size: 9.0 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 7.0 KiB |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 878 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 653 B |
After Width: | Height: | Size: 800 B |
After Width: | Height: | Size: 905 B |
After Width: | Height: | Size: 189 KiB |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 839 B |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 5.9 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 427 B |
After Width: | Height: | Size: 627 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 988 B |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 5.0 KiB |
After Width: | Height: | Size: 875 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 80 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 3.2 KiB |
After Width: | Height: | Size: 589 B |
After Width: | Height: | Size: 3.4 KiB |
After Width: | Height: | Size: 565 B |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 967 B |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 43 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 4.0 KiB |