mirror of https://github.com/OCA/social.git
[12.0][MIG] mail_optional_follower_notification
parent
c26f6739da
commit
431d57a6f6
|
@ -1,58 +1,91 @@
|
|||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
|
||||
===================================
|
||||
Mail optional follower notification
|
||||
===================================
|
||||
|
||||
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! This file is generated by oca-gen-addon-readme !!
|
||||
!! changes will be overwritten. !!
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
|
||||
:target: https://odoo-community.org/page/development-status
|
||||
:alt: Beta
|
||||
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
|
||||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
||||
:alt: License: AGPL-3
|
||||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsocial-lightgray.png?logo=github
|
||||
:target: https://github.com/OCA/social/tree/12.0/mail_optional_follower_notification
|
||||
:alt: OCA/social
|
||||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
|
||||
:target: https://translation.odoo-community.org/projects/social-12-0/social-12-0-mail_optional_follower_notification
|
||||
:alt: Translate me on Weblate
|
||||
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
|
||||
:target: https://runbot.odoo-community.org/runbot/205/12.0
|
||||
:alt: Try me on Runbot
|
||||
|
||||
====================================
|
||||
Mail optional follower notifications
|
||||
====================================
|
||||
|badge1| |badge2| |badge3| |badge4| |badge5|
|
||||
|
||||
This module adds the possibility to choose if you want to automatically
|
||||
notify followers on mail.compose.message. By default, Odoo notify
|
||||
automatically all followers.
|
||||
|
||||
**Table of contents**
|
||||
|
||||
.. contents::
|
||||
:local:
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
To use this module, you need to use the checkbox near "Followers of the document and" on mail.compose.message:
|
||||
To use this module, you need to use the checkbox near "Followers of the
|
||||
document and" on mail.compose.message:
|
||||
|
||||
This field it's initialized to true to keep the standard behavior.
|
||||
|
||||
.. figure:: static/description/optional_follower_001.png
|
||||
.. figure:: https://raw.githubusercontent.com/OCA/social/12.0/mail_optional_follower_notification/static/description/optional_follower_001.png
|
||||
:alt: Default checkbox
|
||||
|
||||
.. figure:: static/description/optional_follower_002.png
|
||||
.. figure:: https://raw.githubusercontent.com/OCA/social/12.0/mail_optional_follower_notification/static/description/optional_follower_002.png
|
||||
:alt: Checkbox to avoid to notify automatically followers
|
||||
|
||||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
|
||||
:alt: Try me on Runbot
|
||||
:target: https://runbot.odoo-community.org/runbot/205/10.0
|
||||
|
||||
|
||||
Bug Tracker
|
||||
===========
|
||||
|
||||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/social/issues>`_.
|
||||
In case of trouble, please check there if your issue has already been reported.
|
||||
If you spotted it first, help us smashing it by providing a detailed and welcomed feedback.
|
||||
If you spotted it first, help us smashing it by providing a detailed and welcomed
|
||||
`feedback <https://github.com/OCA/social/issues/new?body=module:%20mail_optional_follower_notification%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||
|
||||
Do not contact contributors directly about support or help with technical issues.
|
||||
|
||||
Credits
|
||||
=======
|
||||
|
||||
Authors
|
||||
~~~~~~~
|
||||
|
||||
* ACSONE SA/NV
|
||||
|
||||
Contributors
|
||||
------------
|
||||
~~~~~~~~~~~~
|
||||
|
||||
* Adrien Peiffer <adrien.peiffer@acsone.eu>
|
||||
* Laurent Mignon <laurent.mignon@acsone.eu>
|
||||
* Andrea Stirpe <a.stirpe@onestein.nl>
|
||||
|
||||
Maintainer
|
||||
----------
|
||||
Maintainers
|
||||
~~~~~~~~~~~
|
||||
|
||||
This module is maintained by the OCA.
|
||||
|
||||
.. image:: https://odoo-community.org/logo.png
|
||||
:alt: Odoo Community Association
|
||||
:target: https://odoo-community.org
|
||||
|
||||
This module is maintained by the OCA.
|
||||
OCA, or the Odoo Community Association, is a nonprofit organization whose
|
||||
mission is to support the collaborative development of Odoo features and
|
||||
promote its widespread use.
|
||||
|
||||
OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.
|
||||
This module is part of the `OCA/social <https://github.com/OCA/social/tree/12.0/mail_optional_follower_notification>`_ project on GitHub.
|
||||
|
||||
To contribute to this module, please visit https://odoo-community.org.
|
||||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2016 ACSONE SA/NV (<http://acsone.eu>)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from . import models
|
||||
from . import wizard
|
||||
|
|
|
@ -1,22 +1,18 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2016 ACSONE SA/NV (<http://acsone.eu>)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
{
|
||||
'name': "Mail optional follower notification",
|
||||
|
||||
'summary': """
|
||||
Choose if you want to automatically notify followers
|
||||
on mail.compose.message""",
|
||||
'author': 'ACSONE SA/NV,'
|
||||
'Odoo Community Association (OCA)',
|
||||
'website': "http://acsone.eu",
|
||||
'category': 'Social Network',
|
||||
'version': '10.0.1.0.1',
|
||||
'license': 'AGPL-3',
|
||||
'depends': [
|
||||
'mail',
|
||||
"name": "Mail optional follower notification",
|
||||
"summary": "Choose to notify followers on mail.compose.message",
|
||||
"author": "ACSONE SA/NV,"
|
||||
"Odoo Community Association (OCA)",
|
||||
"website": "https://github.com/OCA/social",
|
||||
"category": "Social Network",
|
||||
"version": "12.0.1.0.0",
|
||||
"license": "AGPL-3",
|
||||
"depends": [
|
||||
"mail",
|
||||
],
|
||||
'data': [
|
||||
'wizard/mail_compose_message_view.xml',
|
||||
"data": [
|
||||
"wizard/mail_compose_message_view.xml",
|
||||
],
|
||||
}
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2016 ACSONE SA/NV (<http://acsone.eu>)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from . import mail_message
|
||||
from . import res_partner
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2016 ACSONE SA/NV (<http://acsone.eu>)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import models, api
|
||||
|
||||
|
@ -14,16 +13,18 @@ class MailMessage(models.Model):
|
|||
if not ctx.get('notify_followers') and values.get('partner_ids'):
|
||||
partner_list = self.resolve_2many_commands(
|
||||
'partner_ids', values.get('partner_ids'), fields=['id'])
|
||||
force_partners_to_notify = [d['id'] for d in partner_list]
|
||||
ctx['force_partners_to_notify'] = force_partners_to_notify
|
||||
ctx['force_partners_to_notify'] = [d['id'] for d in partner_list]
|
||||
return super(MailMessage, self.with_context(ctx)).create(values)
|
||||
|
||||
@api.multi
|
||||
def _notify(self, force_send=False, send_after_commit=True,
|
||||
user_signature=True):
|
||||
res = super(MailMessage, self)._notify(
|
||||
force_send=force_send, send_after_commit=send_after_commit,
|
||||
user_signature=user_signature)
|
||||
def _notify(self, record, msg_vals, force_send=False,
|
||||
send_after_commit=True, model_description=False,
|
||||
mail_auto_delete=True):
|
||||
res = super()._notify(
|
||||
record, msg_vals, force_send=force_send,
|
||||
send_after_commit=send_after_commit,
|
||||
model_description=model_description,
|
||||
mail_auto_delete=mail_auto_delete)
|
||||
if self.env.context.get('force_partners_to_notify'):
|
||||
# Needaction only for recipients
|
||||
self.needaction_partner_ids = [
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2016 ACSONE SA/NV (<http://acsone.eu>)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import models, api
|
||||
|
||||
|
@ -8,13 +7,16 @@ from odoo import models, api
|
|||
class ResPartner(models.Model):
|
||||
_inherit = 'res.partner'
|
||||
|
||||
@api.multi
|
||||
def _notify(self, message, force_send=False, send_after_commit=True,
|
||||
user_signature=True):
|
||||
@api.model
|
||||
def _notify(self, message, rdata, record, force_send=False,
|
||||
send_after_commit=True, model_description=False,
|
||||
mail_auto_delete=True):
|
||||
if self.env.context.get('force_partners_to_notify'):
|
||||
partners_to_notify =\
|
||||
self.env.context.get('force_partners_to_notify')
|
||||
self = self.filtered(lambda p: p.id in partners_to_notify)
|
||||
super(ResPartner, self)._notify(
|
||||
message, force_send=force_send,
|
||||
send_after_commit=send_after_commit, user_signature=user_signature)
|
||||
record = self.filtered(lambda p: p.id in partners_to_notify)
|
||||
return super()._notify(
|
||||
message, rdata, record,
|
||||
force_send=force_send, send_after_commit=send_after_commit,
|
||||
model_description=model_description,
|
||||
mail_auto_delete=mail_auto_delete)
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
* Adrien Peiffer <adrien.peiffer@acsone.eu>
|
||||
* Laurent Mignon <laurent.mignon@acsone.eu>
|
||||
* Andrea Stirpe <a.stirpe@onestein.nl>
|
|
@ -0,0 +1,3 @@
|
|||
This module adds the possibility to choose if you want to automatically
|
||||
notify followers on mail.compose.message. By default, Odoo notify
|
||||
automatically all followers.
|
|
@ -0,0 +1,10 @@
|
|||
To use this module, you need to use the checkbox near "Followers of the
|
||||
document and" on mail.compose.message:
|
||||
|
||||
This field it's initialized to true to keep the standard behavior.
|
||||
|
||||
.. figure:: static/description/optional_follower_001.png
|
||||
:alt: Default checkbox
|
||||
|
||||
.. figure:: static/description/optional_follower_002.png
|
||||
:alt: Checkbox to avoid to notify automatically followers
|
|
@ -1,5 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2016 ACSONE SA/NV (<http://acsone.eu>)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from . import test_mail_optional_follower_notifications
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2016 ACSONE SA/NV (<http://acsone.eu>)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo.tests import common
|
||||
|
||||
|
@ -8,7 +7,7 @@ from odoo.tests import common
|
|||
class TestMailOptionalFollowernotifications(common.TransactionCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestMailOptionalFollowernotifications, self).setUp()
|
||||
super().setUp()
|
||||
self.partner_obj = self.env['res.partner']
|
||||
self.partner_01 = self.env.ref('base.res_partner_2')
|
||||
self.demo_user = self.env.ref('base.user_demo')
|
||||
|
@ -22,7 +21,8 @@ class TestMailOptionalFollowernotifications(common.TransactionCase):
|
|||
'default_composition_mode': 'comment',
|
||||
})
|
||||
mail_compose = self.env['mail.compose.message']
|
||||
self.partner_01.message_subscribe_users(user_ids=[self.demo_user.id])
|
||||
self.partner_01.message_subscribe(
|
||||
partner_ids=[self.demo_user.partner_id.id])
|
||||
values = mail_compose.with_context(ctx)\
|
||||
.onchange_template_id(False, 'comment', 'res.partner',
|
||||
self.partner_01.id)['value']
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2016 ACSONE SA/NV (<http://acsone.eu>)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from . import mail_compose_message
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2016 ACSONE SA/NV (<http://acsone.eu>)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import models, fields, api
|
||||
|
||||
|
@ -12,9 +11,10 @@ class MailComposeMessage(models.TransientModel):
|
|||
|
||||
@api.multi
|
||||
def send_mail(self, auto_commit=False):
|
||||
ctx = self.env.context.copy()
|
||||
for wizard in self:
|
||||
wizard = wizard.with_context(
|
||||
notify_followers=wizard.notify_followers)
|
||||
ctx['notify_followers'] = wizard.notify_followers
|
||||
wizard = wizard.with_context(ctx)
|
||||
super(MailComposeMessage, wizard).send_mail(
|
||||
auto_commit=auto_commit)
|
||||
return {'type': 'ir.actions.act_window_close'}
|
||||
|
|
|
@ -1,18 +1,17 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data noupdate="0">
|
||||
<record model="ir.ui.view" id="email_compose_message_wizard_inherit_form">
|
||||
<field name="name">mail.compose.message.form (mail_optional_autofollow)</field>
|
||||
<field name="model">mail.compose.message</field>
|
||||
<field name="inherit_id" ref="mail.email_compose_message_wizard_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//div[field[@name='partner_ids']]/span[2]" position="before">
|
||||
<field name="notify_followers" attrs="{'invisible': [('composition_mode', '=', 'mass_mail')]}"/>
|
||||
</xpath>
|
||||
<xpath expr="//div[field[@name='partner_ids']]/span[2]" position="inside">
|
||||
<span attrs="{'invisible': [('notify_followers', '=', True)]}" style="color: red;"> - Warning : Followers will not be notified but they can access the notification directly from the document (if they are allowed to)</span>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
|
||||
<record id="email_compose_message_wizard_form" model="ir.ui.view">
|
||||
<field name="model">mail.compose.message</field>
|
||||
<field name="inherit_id" ref="mail.email_compose_message_wizard_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//div[field[@name='partner_ids']]/span[2]" position="before">
|
||||
<field name="notify_followers" attrs="{'invisible': [('composition_mode', '=', 'mass_mail')]}"/>
|
||||
</xpath>
|
||||
<xpath expr="//div[field[@name='partner_ids']]/span[2]" position="inside">
|
||||
<span attrs="{'invisible': [('notify_followers', '=', True)]}" style="color: red;"> - Warning : Followers will not be notified but they can access the notification directly from the document (if they are allowed to)</span>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
Loading…
Reference in New Issue