Holger Brunn
6 years ago
27 changed files with 802 additions and 404 deletions
-
86mail_follower_custom_notification/README.rst
-
3mail_follower_custom_notification/__init__.py
-
4mail_follower_custom_notification/__manifest__.py
-
4mail_follower_custom_notification/controllers/__init__.py
-
29mail_follower_custom_notification/controllers/mail_controller.py
-
5mail_follower_custom_notification/models/__init__.py
-
92mail_follower_custom_notification/models/base_patch_models_mixin.py
-
5mail_follower_custom_notification/models/mail_followers.py
-
23mail_follower_custom_notification/models/mail_message.py
-
16mail_follower_custom_notification/models/mail_message_subtype.py
-
33mail_follower_custom_notification/models/mail_notification.py
-
42mail_follower_custom_notification/models/mail_thread.py
-
30mail_follower_custom_notification/models/res_partner.py
-
10mail_follower_custom_notification/readme/CONFIGURE.rst
-
1mail_follower_custom_notification/readme/CONTRIBUTORS.rst
-
1mail_follower_custom_notification/readme/CREDITS.rst
-
6mail_follower_custom_notification/readme/DESCRIPTION.rst
-
442mail_follower_custom_notification/static/description/index.html
-
15mail_follower_custom_notification/static/src/css/mail_follower_custom_notification.css
-
94mail_follower_custom_notification/static/src/js/mail_follower_custom_notification.js
-
15mail_follower_custom_notification/static/src/xml/mail_follower_custom_notification.xml
-
86mail_follower_custom_notification/tests/test_mail_follower_custom_notification.py
-
8mail_follower_custom_notification/views/mail_message_subtype.xml
-
6mail_follower_custom_notification/views/templates.xml
-
2mail_follower_custom_notification/wizards/__init__.py
-
5mail_follower_custom_notification/wizards/mail_subtype_assign_custom_notifications.py
-
11mail_follower_custom_notification/wizards/mail_subtype_assign_custom_notifications.xml
@ -1,73 +1,97 @@ |
|||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg |
|||
:alt: License: AGPL-3 |
|||
|
|||
========================================== |
|||
Custom notification settings for followers |
|||
========================================== |
|||
|
|||
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|||
!! 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/10.0/mail_follower_custom_notification |
|||
:alt: OCA/social |
|||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png |
|||
:target: https://translation.odoo-community.org/projects/social-10-0/social-10-0-mail_follower_custom_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/10.0 |
|||
:alt: Try me on Runbot |
|||
|
|||
|badge1| |badge2| |badge3| |badge4| |badge5| |
|||
|
|||
In standard Odoo, receiving mail notifications is an all or nothing affair. |
|||
This module allows you users to decide per followed record if they want to |
|||
receive emails or not. Further, they can choose to receive notification about |
|||
This module allows users to decide per followed record if they want to |
|||
receive emails or not. Further, they can choose to receive notifications about |
|||
their own messages. |
|||
|
|||
You can also set defaults for this settings on the subtype in question. |
|||
|
|||
**Table of contents** |
|||
|
|||
.. contents:: |
|||
:local: |
|||
|
|||
Configuration |
|||
============= |
|||
|
|||
When followers open their subscriptions, they will be offered the choice to |
|||
override mail settings and to force being notified about their own messages. |
|||
|
|||
Note subscriptions are only editable for users of the `Technical settings` |
|||
group. |
|||
|
|||
You can add defaults per message subtype for this settings in Settings / |
|||
Technical / Email / Subtypes. Here, you also have the opportunity to apply |
|||
those defaults to existing subscriptions. Note that this overrides all |
|||
customizations your users already have done. |
|||
|
|||
Usage |
|||
===== |
|||
|
|||
To use this module, for example you need to: |
|||
|
|||
- Go to Sales -> Sales -> Customers |
|||
- Go Inside any customer and in the right-botton corner press "Follow" button |
|||
- Unfold Following menu and check new functionality with "mail notificacions" |
|||
|
|||
|
|||
.. 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/8.0 |
|||
|
|||
For further information, please visit: |
|||
|
|||
* https://www.odoo.com/forum/help-1 |
|||
|
|||
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 |
|||
`here <https://github.com/OCA/social/issues/new?body=module:%20mail_follower_custom_notification%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. |
|||
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_follower_custom_notification%0Aversion:%2010.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 |
|||
~~~~~~~ |
|||
|
|||
* Therp BV |
|||
|
|||
Contributors |
|||
------------ |
|||
~~~~~~~~~~~~ |
|||
|
|||
* Holger Brunn <hbrunn@therp.nl> |
|||
|
|||
Maintainer |
|||
---------- |
|||
Other credits |
|||
~~~~~~~~~~~~~ |
|||
|
|||
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_. |
|||
|
|||
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. |
|||
|
|||
To contribute to this module, please visit http://odoo-community.org. |
|||
This module is part of the `OCA/social <https://github.com/OCA/social/tree/10.0/mail_follower_custom_notification>`_ project on GitHub. |
|||
|
|||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
@ -1,5 +1,6 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2015 Therp BV <http://therp.nl> |
|||
# Copyright 2015 Therp BV <http://therp.nl> |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
from . import models |
|||
from . import wizards |
|||
from . import controllers |
@ -1,9 +1,9 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2015 Therp BV <http://therp.nl> |
|||
# Copyright 2015 Therp BV <http://therp.nl> |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
{ |
|||
"name": "Custom notification settings for followers", |
|||
"version": "8.0.1.0.0", |
|||
"version": "10.0.1.0.0", |
|||
"author": "Therp BV,Odoo Community Association (OCA)", |
|||
"license": "AGPL-3", |
|||
"category": "Social Network", |
@ -0,0 +1,4 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2019 Therp BV <https://therp.nl> |
|||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). |
|||
from . import mail_controller |
@ -0,0 +1,29 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2019 Therp BV <https://therp.nl> |
|||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). |
|||
from odoo import http |
|||
from odoo.http import request |
|||
from odoo.addons.mail.controllers.main import MailController as _MailController |
|||
|
|||
|
|||
class MailController(_MailController): |
|||
@http.route() |
|||
def read_subscription_data(self, res_model, follower_id): |
|||
"""Add custom notification data to subscriptions""" |
|||
subtypes_list = super(MailController, self).read_subscription_data( |
|||
res_model, follower_id, |
|||
) |
|||
follower = request.env['mail.followers'].browse(follower_id) |
|||
for subtype_dict in subtypes_list: |
|||
subtype = request.env['mail.message.subtype'].browse( |
|||
subtype_dict['id'] |
|||
) |
|||
subtype_dict['force_mail'] = 'default' |
|||
if subtype in follower.force_mail_subtype_ids: |
|||
subtype_dict['force_mail'] = 'force_yes' |
|||
elif subtype in follower.force_nomail_subtype_ids: |
|||
subtype_dict['force_mail'] = 'force_no' |
|||
subtype_dict['force_own'] = ( |
|||
subtype in follower.force_own_subtype_ids |
|||
) |
|||
return subtypes_list |
@ -1,9 +1,8 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2015 Therp BV <http://therp.nl> |
|||
# Copyright 2015 Therp BV <http://therp.nl> |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
from . import base_patch_models_mixin |
|||
from . import mail_followers |
|||
from . import mail_thread |
|||
from . import mail_message |
|||
from . import mail_notification |
|||
from . import mail_message_subtype |
|||
from . import res_partner |
@ -1,92 +0,0 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2016 Therp BV <http://therp.nl> |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
import logging |
|||
from openerp import models |
|||
|
|||
|
|||
_logger = logging.getLogger(__file__) |
|||
|
|||
|
|||
# TODO: this should be a helper module to cetralize the point of failure |
|||
# in case this introduces tacit bugs |
|||
class BasePatchModelsMixin(models.AbstractModel): |
|||
""" |
|||
This is a mixin class meant to simplify working with patches |
|||
on BaseModel or on abstract models like mail.thread. |
|||
If you just change them, models created earlier will lack the |
|||
attributes you add. Just inherit from this mixin, it will check |
|||
which existing models need your changes and apply them. |
|||
|
|||
In your module, do something like |
|||
|
|||
class MailThread(models.AbstractModel): |
|||
_name = 'mail.thread' |
|||
_inherit = ['base.patch.models.mixin', 'mail.thread'] |
|||
|
|||
in case you need to patch BaseModel, say |
|||
|
|||
class BaseModel(models.BaseModel): |
|||
_name = 'my.unique.model.name' |
|||
_inherit = 'base.patch.models.mixin' |
|||
|
|||
Your code will behave as if it was an inherited class of the class you pass |
|||
in the second parameter to _base_patch_models. |
|||
""" |
|||
_name = 'base.patch.models.mixin' |
|||
|
|||
def _base_patch_models(self, cr, our_class=None, parent_class=None): |
|||
"""iterate through existing models to apply our changes there if |
|||
necessary""" |
|||
if self._name == BasePatchModelsMixin._name: |
|||
return |
|||
my_bases = self.__class__.__bases__ |
|||
for i in range(max(len(my_bases) - 1, 0)): |
|||
if my_bases[i]._name == BasePatchModelsMixin._name: |
|||
our_class = my_bases[i - 1] |
|||
parent_class = my_bases[i + 1] |
|||
inherit = [self._inherit]\ |
|||
if isinstance(self._inherit, basestring) else self._inherit |
|||
for i in range(len(my_bases) - 1, 0, -1): |
|||
# this can be different from the above if our mixin is used |
|||
# multiple times on the same model |
|||
if my_bases[i]._name in inherit: |
|||
parent_class = my_bases[i] |
|||
break |
|||
if self.__class__.__bases__[-1] == BasePatchModelsMixin\ |
|||
and not our_class or not parent_class: |
|||
our_class = self.__class__.__bases__[-2] |
|||
parent_class = models.BaseModel |
|||
if not our_class or not parent_class: |
|||
_logger.info( |
|||
'Failed to autodetect own class or parent class for %s, ' |
|||
'ignoring', self._name) |
|||
return |
|||
|
|||
for model_name, model_object in self.pool.models.iteritems(): |
|||
if not isinstance(model_object, parent_class): |
|||
continue |
|||
if isinstance(model_object, our_class): |
|||
continue |
|||
if not isinstance(model_object, models.Model): |
|||
continue |
|||
bases = list(model_object.__class__.__bases__) |
|||
position = 1 |
|||
if parent_class == models.BaseModel: |
|||
position = len(bases) |
|||
else: |
|||
for i in range(len(bases) - 1, position, -1): |
|||
if bases[i]._name in inherit: |
|||
position = i |
|||
break |
|||
bases.insert(position, our_class) |
|||
model_object.__class__.__bases__ = tuple(bases) |
|||
|
|||
def _register_hook(self, cr): |
|||
self._base_patch_models(cr) |
|||
for base in self.__class__.__bases__: |
|||
if not hasattr(super(base, self), '_register_hook'): |
|||
return |
|||
if super(base, self)._register_hook != self._register_hook: |
|||
return super(base, self)._register_hook.__func__( |
|||
super(base, self), cr) |
@ -1,25 +1,28 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2015 Therp BV <http://therp.nl> |
|||
# Copyright 2015 Therp BV <http://therp.nl> |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
from openerp import api, models |
|||
from odoo import api, models |
|||
|
|||
|
|||
class MailMessage(models.Model): |
|||
_inherit = 'mail.message' |
|||
|
|||
@api.multi |
|||
def _notify(self, force_send=False, user_signature=True): |
|||
def _notify( |
|||
self, force_send=False, send_after_commit=True, user_signature=True, |
|||
): |
|||
"""notify author if she's a follower and turned on force_own""" |
|||
self.ensure_one() |
|||
if self.subtype_id and self.model and self.res_id: |
|||
author_follower = self.env['mail.followers'].search([ |
|||
if self.subtype_id and self.model and self.res_id and self.env[ |
|||
'mail.followers' |
|||
].search([ |
|||
('res_model', '=', self.model), |
|||
('res_id', '=', self.res_id), |
|||
('partner_id', '=', self.author_id.id), |
|||
('force_own_subtype_ids', '=', self.subtype_id.id), |
|||
]) |
|||
self.env['mail.notification']._notify( |
|||
self.id, partners_to_notify=author_follower.partner_id.ids, |
|||
force_send=force_send, user_signature=user_signature) |
|||
]): |
|||
self = self.with_context(mail_notify_author=True) |
|||
return super(MailMessage, self)._notify( |
|||
self.id, force_send=force_send, user_signature=user_signature) |
|||
force_send=force_send, send_after_commit=send_after_commit, |
|||
user_signature=user_signature, |
|||
) |
@ -1,33 +0,0 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2015 Therp BV <http://therp.nl> |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
from openerp import api, models |
|||
|
|||
|
|||
class MailNotification(models.Model): |
|||
_inherit = 'mail.notification' |
|||
|
|||
@api.multi |
|||
def get_partners_to_email(self, message): |
|||
partner_ids = super(MailNotification, self)\ |
|||
.get_partners_to_email(message) |
|||
for this in self: |
|||
follower = self.env['mail.followers'].search([ |
|||
('res_model', '=', message.model), |
|||
('res_id', '=', message.res_id), |
|||
('partner_id', '=', this.partner_id.id), |
|||
'|', '|', |
|||
('force_nomail_subtype_ids', '=', message.subtype_id.id), |
|||
('force_mail_subtype_ids', '=', message.subtype_id.id), |
|||
('force_own_subtype_ids', '=', message.subtype_id.id), |
|||
]) |
|||
if not follower: |
|||
continue |
|||
if (message.subtype_id in follower.force_mail_subtype_ids or |
|||
message.subtype_id in follower.force_own_subtype_ids) and\ |
|||
this.partner_id.id not in partner_ids: |
|||
partner_ids.append(this.partner_id.id) |
|||
if message.subtype_id in follower.force_nomail_subtype_ids and\ |
|||
this.partner_id.id in partner_ids: |
|||
partner_ids.remove(this.partner_id.id) |
|||
return partner_ids |
@ -0,0 +1,30 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2019 Therp BV <https://therp.nl> |
|||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). |
|||
from odoo import api, models |
|||
|
|||
|
|||
class ResPartner(models.Model): |
|||
_inherit = 'res.partner' |
|||
|
|||
@api.multi |
|||
def _notify_by_email( |
|||
self, message, force_send=False, send_after_commit=True, |
|||
user_signature=True, |
|||
): |
|||
"""remove partners from `self` who requested not to be mailed, |
|||
add the ones who did the opposite""" |
|||
domain = [ |
|||
('res_model', '=', message.model), |
|||
('res_id', '=', message.res_id), |
|||
] |
|||
self |= self.env['mail.followers'].search( |
|||
domain + [('force_mail_subtype_ids', '=', message.subtype_id.id)] |
|||
).mapped('partner_id') |
|||
self -= self.env['mail.followers'].search( |
|||
domain + [('force_nomail_subtype_ids', '=', message.subtype_id.id)] |
|||
).mapped('partner_id') |
|||
return super(ResPartner, self)._notify_by_email( |
|||
message, force_send=force_send, |
|||
send_after_commit=send_after_commit, user_signature=user_signature, |
|||
) |
@ -0,0 +1,10 @@ |
|||
When followers open their subscriptions, they will be offered the choice to |
|||
override mail settings and to force being notified about their own messages. |
|||
|
|||
Note subscriptions are only editable for users of the `Technical settings` |
|||
group. |
|||
|
|||
You can add defaults per message subtype for this settings in Settings / |
|||
Technical / Email / Subtypes. Here, you also have the opportunity to apply |
|||
those defaults to existing subscriptions. Note that this overrides all |
|||
customizations your users already have done. |
@ -0,0 +1 @@ |
|||
* Holger Brunn <hbrunn@therp.nl> |
@ -0,0 +1 @@ |
|||
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_. |
@ -0,0 +1,6 @@ |
|||
In standard Odoo, receiving mail notifications is an all or nothing affair. |
|||
This module allows users to decide per followed record if they want to |
|||
receive emails or not. Further, they can choose to receive notifications about |
|||
their own messages. |
|||
|
|||
You can also set defaults for this settings on the subtype in question. |
@ -0,0 +1,442 @@ |
|||
<?xml version="1.0" encoding="utf-8" ?> |
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
|||
<head> |
|||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
|||
<meta name="generator" content="Docutils 0.14: http://docutils.sourceforge.net/" /> |
|||
<title>Custom notification settings for followers</title> |
|||
<style type="text/css"> |
|||
|
|||
/* |
|||
:Author: David Goodger (goodger@python.org) |
|||
:Id: $Id: html4css1.css 7952 2016-07-26 18:15:59Z milde $ |
|||
:Copyright: This stylesheet has been placed in the public domain. |
|||
|
|||
Default cascading style sheet for the HTML output of Docutils. |
|||
|
|||
See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to |
|||
customize this style sheet. |
|||
*/ |
|||
|
|||
/* used to remove borders from tables and images */ |
|||
.borderless, table.borderless td, table.borderless th { |
|||
border: 0 } |
|||
|
|||
table.borderless td, table.borderless th { |
|||
/* Override padding for "table.docutils td" with "! important". |
|||
The right padding separates the table cells. */ |
|||
padding: 0 0.5em 0 0 ! important } |
|||
|
|||
.first { |
|||
/* Override more specific margin styles with "! important". */ |
|||
margin-top: 0 ! important } |
|||
|
|||
.last, .with-subtitle { |
|||
margin-bottom: 0 ! important } |
|||
|
|||
.hidden { |
|||
display: none } |
|||
|
|||
.subscript { |
|||
vertical-align: sub; |
|||
font-size: smaller } |
|||
|
|||
.superscript { |
|||
vertical-align: super; |
|||
font-size: smaller } |
|||
|
|||
a.toc-backref { |
|||
text-decoration: none ; |
|||
color: black } |
|||
|
|||
blockquote.epigraph { |
|||
margin: 2em 5em ; } |
|||
|
|||
dl.docutils dd { |
|||
margin-bottom: 0.5em } |
|||
|
|||
object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] { |
|||
overflow: hidden; |
|||
} |
|||
|
|||
/* Uncomment (and remove this text!) to get bold-faced definition list terms |
|||
dl.docutils dt { |
|||
font-weight: bold } |
|||
*/ |
|||
|
|||
div.abstract { |
|||
margin: 2em 5em } |
|||
|
|||
div.abstract p.topic-title { |
|||
font-weight: bold ; |
|||
text-align: center } |
|||
|
|||
div.admonition, div.attention, div.caution, div.danger, div.error, |
|||
div.hint, div.important, div.note, div.tip, div.warning { |
|||
margin: 2em ; |
|||
border: medium outset ; |
|||
padding: 1em } |
|||
|
|||
div.admonition p.admonition-title, div.hint p.admonition-title, |
|||
div.important p.admonition-title, div.note p.admonition-title, |
|||
div.tip p.admonition-title { |
|||
font-weight: bold ; |
|||
font-family: sans-serif } |
|||
|
|||
div.attention p.admonition-title, div.caution p.admonition-title, |
|||
div.danger p.admonition-title, div.error p.admonition-title, |
|||
div.warning p.admonition-title, .code .error { |
|||
color: red ; |
|||
font-weight: bold ; |
|||
font-family: sans-serif } |
|||
|
|||
/* Uncomment (and remove this text!) to get reduced vertical space in |
|||
compound paragraphs. |
|||
div.compound .compound-first, div.compound .compound-middle { |
|||
margin-bottom: 0.5em } |
|||
|
|||
div.compound .compound-last, div.compound .compound-middle { |
|||
margin-top: 0.5em } |
|||
*/ |
|||
|
|||
div.dedication { |
|||
margin: 2em 5em ; |
|||
text-align: center ; |
|||
font-style: italic } |
|||
|
|||
div.dedication p.topic-title { |
|||
font-weight: bold ; |
|||
font-style: normal } |
|||
|
|||
div.figure { |
|||
margin-left: 2em ; |
|||
margin-right: 2em } |
|||
|
|||
div.footer, div.header { |
|||
clear: both; |
|||
font-size: smaller } |
|||
|
|||
div.line-block { |
|||
display: block ; |
|||
margin-top: 1em ; |
|||
margin-bottom: 1em } |
|||
|
|||
div.line-block div.line-block { |
|||
margin-top: 0 ; |
|||
margin-bottom: 0 ; |
|||
margin-left: 1.5em } |
|||
|
|||
div.sidebar { |
|||
margin: 0 0 0.5em 1em ; |
|||
border: medium outset ; |
|||
padding: 1em ; |
|||
background-color: #ffffee ; |
|||
width: 40% ; |
|||
float: right ; |
|||
clear: right } |
|||
|
|||
div.sidebar p.rubric { |
|||
font-family: sans-serif ; |
|||
font-size: medium } |
|||
|
|||
div.system-messages { |
|||
margin: 5em } |
|||
|
|||
div.system-messages h1 { |
|||
color: red } |
|||
|
|||
div.system-message { |
|||
border: medium outset ; |
|||
padding: 1em } |
|||
|
|||
div.system-message p.system-message-title { |
|||
color: red ; |
|||
font-weight: bold } |
|||
|
|||
div.topic { |
|||
margin: 2em } |
|||
|
|||
h1.section-subtitle, h2.section-subtitle, h3.section-subtitle, |
|||
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle { |
|||
margin-top: 0.4em } |
|||
|
|||
h1.title { |
|||
text-align: center } |
|||
|
|||
h2.subtitle { |
|||
text-align: center } |
|||
|
|||
hr.docutils { |
|||
width: 75% } |
|||
|
|||
img.align-left, .figure.align-left, object.align-left, table.align-left { |
|||
clear: left ; |
|||
float: left ; |
|||
margin-right: 1em } |
|||
|
|||
img.align-right, .figure.align-right, object.align-right, table.align-right { |
|||
clear: right ; |
|||
float: right ; |
|||
margin-left: 1em } |
|||
|
|||
img.align-center, .figure.align-center, object.align-center { |
|||
display: block; |
|||
margin-left: auto; |
|||
margin-right: auto; |
|||
} |
|||
|
|||
table.align-center { |
|||
margin-left: auto; |
|||
margin-right: auto; |
|||
} |
|||
|
|||
.align-left { |
|||
text-align: left } |
|||
|
|||
.align-center { |
|||
clear: both ; |
|||
text-align: center } |
|||
|
|||
.align-right { |
|||
text-align: right } |
|||
|
|||
/* reset inner alignment in figures */ |
|||
div.align-right { |
|||
text-align: inherit } |
|||
|
|||
/* div.align-center * { */ |
|||
/* text-align: left } */ |
|||
|
|||
.align-top { |
|||
vertical-align: top } |
|||
|
|||
.align-middle { |
|||
vertical-align: middle } |
|||
|
|||
.align-bottom { |
|||
vertical-align: bottom } |
|||
|
|||
ol.simple, ul.simple { |
|||
margin-bottom: 1em } |
|||
|
|||
ol.arabic { |
|||
list-style: decimal } |
|||
|
|||
ol.loweralpha { |
|||
list-style: lower-alpha } |
|||
|
|||
ol.upperalpha { |
|||
list-style: upper-alpha } |
|||
|
|||
ol.lowerroman { |
|||
list-style: lower-roman } |
|||
|
|||
ol.upperroman { |
|||
list-style: upper-roman } |
|||
|
|||
p.attribution { |
|||
text-align: right ; |
|||
margin-left: 50% } |
|||
|
|||
p.caption { |
|||
font-style: italic } |
|||
|
|||
p.credits { |
|||
font-style: italic ; |
|||
font-size: smaller } |
|||
|
|||
p.label { |
|||
white-space: nowrap } |
|||
|
|||
p.rubric { |
|||
font-weight: bold ; |
|||
font-size: larger ; |
|||
color: maroon ; |
|||
text-align: center } |
|||
|
|||
p.sidebar-title { |
|||
font-family: sans-serif ; |
|||
font-weight: bold ; |
|||
font-size: larger } |
|||
|
|||
p.sidebar-subtitle { |
|||
font-family: sans-serif ; |
|||
font-weight: bold } |
|||
|
|||
p.topic-title { |
|||
font-weight: bold } |
|||
|
|||
pre.address { |
|||
margin-bottom: 0 ; |
|||
margin-top: 0 ; |
|||
font: inherit } |
|||
|
|||
pre.literal-block, pre.doctest-block, pre.math, pre.code { |
|||
margin-left: 2em ; |
|||
margin-right: 2em } |
|||
|
|||
pre.code .ln { color: grey; } /* line numbers */ |
|||
pre.code, code { background-color: #eeeeee } |
|||
pre.code .comment, code .comment { color: #5C6576 } |
|||
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } |
|||
pre.code .literal.string, code .literal.string { color: #0C5404 } |
|||
pre.code .name.builtin, code .name.builtin { color: #352B84 } |
|||
pre.code .deleted, code .deleted { background-color: #DEB0A1} |
|||
pre.code .inserted, code .inserted { background-color: #A3D289} |
|||
|
|||
span.classifier { |
|||
font-family: sans-serif ; |
|||
font-style: oblique } |
|||
|
|||
span.classifier-delimiter { |
|||
font-family: sans-serif ; |
|||
font-weight: bold } |
|||
|
|||
span.interpreted { |
|||
font-family: sans-serif } |
|||
|
|||
span.option { |
|||
white-space: nowrap } |
|||
|
|||
span.pre { |
|||
white-space: pre } |
|||
|
|||
span.problematic { |
|||
color: red } |
|||
|
|||
span.section-subtitle { |
|||
/* font-size relative to parent (h1..h6 element) */ |
|||
font-size: 80% } |
|||
|
|||
table.citation { |
|||
border-left: solid 1px gray; |
|||
margin-left: 1px } |
|||
|
|||
table.docinfo { |
|||
margin: 2em 4em } |
|||
|
|||
table.docutils { |
|||
margin-top: 0.5em ; |
|||
margin-bottom: 0.5em } |
|||
|
|||
table.footnote { |
|||
border-left: solid 1px black; |
|||
margin-left: 1px } |
|||
|
|||
table.docutils td, table.docutils th, |
|||
table.docinfo td, table.docinfo th { |
|||
padding-left: 0.5em ; |
|||
padding-right: 0.5em ; |
|||
vertical-align: top } |
|||
|
|||
table.docutils th.field-name, table.docinfo th.docinfo-name { |
|||
font-weight: bold ; |
|||
text-align: left ; |
|||
white-space: nowrap ; |
|||
padding-left: 0 } |
|||
|
|||
/* "booktabs" style (no vertical lines) */ |
|||
table.docutils.booktabs { |
|||
border: 0px; |
|||
border-top: 2px solid; |
|||
border-bottom: 2px solid; |
|||
border-collapse: collapse; |
|||
} |
|||
table.docutils.booktabs * { |
|||
border: 0px; |
|||
} |
|||
table.docutils.booktabs th { |
|||
border-bottom: thin solid; |
|||
text-align: left; |
|||
} |
|||
|
|||
h1 tt.docutils, h2 tt.docutils, h3 tt.docutils, |
|||
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils { |
|||
font-size: 100% } |
|||
|
|||
ul.auto-toc { |
|||
list-style-type: none } |
|||
|
|||
</style> |
|||
</head> |
|||
<body> |
|||
<div class="document" id="custom-notification-settings-for-followers"> |
|||
<h1 class="title">Custom notification settings for followers</h1> |
|||
|
|||
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|||
!! This file is generated by oca-gen-addon-readme !! |
|||
!! changes will be overwritten. !! |
|||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> |
|||
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/social/tree/10.0/mail_follower_custom_notification"><img alt="OCA/social" src="https://img.shields.io/badge/github-OCA%2Fsocial-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/social-10-0/social-10-0-mail_follower_custom_notification"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/205/10.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p> |
|||
<p>In standard Odoo, receiving mail notifications is an all or nothing affair. |
|||
This module allows users to decide per followed record if they want to |
|||
receive emails or not. Further, they can choose to receive notifications about |
|||
their own messages.</p> |
|||
<p>You can also set defaults for this settings on the subtype in question.</p> |
|||
<p><strong>Table of contents</strong></p> |
|||
<div class="contents local topic" id="contents"> |
|||
<ul class="simple"> |
|||
<li><a class="reference internal" href="#configuration" id="id1">Configuration</a></li> |
|||
<li><a class="reference internal" href="#bug-tracker" id="id2">Bug Tracker</a></li> |
|||
<li><a class="reference internal" href="#credits" id="id3">Credits</a><ul> |
|||
<li><a class="reference internal" href="#authors" id="id4">Authors</a></li> |
|||
<li><a class="reference internal" href="#contributors" id="id5">Contributors</a></li> |
|||
<li><a class="reference internal" href="#other-credits" id="id6">Other credits</a></li> |
|||
<li><a class="reference internal" href="#maintainers" id="id7">Maintainers</a></li> |
|||
</ul> |
|||
</li> |
|||
</ul> |
|||
</div> |
|||
<div class="section" id="configuration"> |
|||
<h1><a class="toc-backref" href="#id1">Configuration</a></h1> |
|||
<p>When followers open their subscriptions, they will be offered the choice to |
|||
override mail settings and to force being notified about their own messages.</p> |
|||
<p>Note subscriptions are only editable for users of the <cite>Technical settings</cite> |
|||
group.</p> |
|||
<p>You can add defaults per message subtype for this settings in Settings / |
|||
Technical / Email / Subtypes. Here, you also have the opportunity to apply |
|||
those defaults to existing subscriptions. Note that this overrides all |
|||
customizations your users already have done.</p> |
|||
</div> |
|||
<div class="section" id="bug-tracker"> |
|||
<h1><a class="toc-backref" href="#id2">Bug Tracker</a></h1> |
|||
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/social/issues">GitHub Issues</a>. |
|||
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 |
|||
<a class="reference external" href="https://github.com/OCA/social/issues/new?body=module:%20mail_follower_custom_notification%0Aversion:%2010.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p> |
|||
<p>Do not contact contributors directly about support or help with technical issues.</p> |
|||
</div> |
|||
<div class="section" id="credits"> |
|||
<h1><a class="toc-backref" href="#id3">Credits</a></h1> |
|||
<div class="section" id="authors"> |
|||
<h2><a class="toc-backref" href="#id4">Authors</a></h2> |
|||
<ul class="simple"> |
|||
<li>Therp BV</li> |
|||
</ul> |
|||
</div> |
|||
<div class="section" id="contributors"> |
|||
<h2><a class="toc-backref" href="#id5">Contributors</a></h2> |
|||
<ul class="simple"> |
|||
<li>Holger Brunn <<a class="reference external" href="mailto:hbrunn@therp.nl">hbrunn@therp.nl</a>></li> |
|||
</ul> |
|||
</div> |
|||
<div class="section" id="other-credits"> |
|||
<h2><a class="toc-backref" href="#id6">Other credits</a></h2> |
|||
<ul class="simple"> |
|||
<li>Odoo Community Association: <a class="reference external" href="https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg">Icon</a>.</li> |
|||
</ul> |
|||
</div> |
|||
<div class="section" id="maintainers"> |
|||
<h2><a class="toc-backref" href="#id7">Maintainers</a></h2> |
|||
<p>This module is maintained by the OCA.</p> |
|||
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a> |
|||
<p>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.</p> |
|||
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/social/tree/10.0/mail_follower_custom_notification">OCA/social</a> project on GitHub.</p> |
|||
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</body> |
|||
</html> |
@ -1,5 +1,18 @@ |
|||
.oe_custom_notification legend |
|||
.o_mail_follower_custom_notification |
|||
{ |
|||
padding: 5px 10px 10px 10px; |
|||
} |
|||
.o_mail_follower_custom_notification fieldset > legend |
|||
{ |
|||
font-size: inherit; |
|||
margin-bottom: 0px; |
|||
} |
|||
.o_mail_follower_custom_notification fieldset > div, |
|||
.o_mail_follower_custom_notification fieldset > div > label |
|||
{ |
|||
white-space: nowrap; |
|||
} |
|||
.o_mail_follower_custom_notification fieldset > div > label |
|||
{ |
|||
font-weight: normal; |
|||
} |
@ -1,79 +1,65 @@ |
|||
// -*- coding: utf-8 -*-
|
|||
//© 2015 Therp BV <http://therp.nl>
|
|||
// Copyright 2015-2019 Therp BV <http://therp.nl>
|
|||
// License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
|||
|
|||
openerp.mail_follower_custom_notification = function(instance) |
|||
{ |
|||
instance.mail_followers.Followers.include({ |
|||
display_subtypes: function(data, id, dialog) |
|||
{ |
|||
var $list = this.$('.oe_subtype_list ul'); |
|||
if (dialog) |
|||
{ |
|||
$list = this.$dialog.$el; |
|||
odoo.define('mail_follower_custom_notification', function(require) { |
|||
'use strict'; |
|||
var core = require('web.core'); |
|||
require('mail.Followers'); |
|||
core.form_widget_registry.get('mail_followers').include({ |
|||
/* eslint-disable-next-line no-unused-vars */ |
|||
display_subtypes:function (data, dialog, display_warning) { |
|||
this._super.apply(this, arguments); |
|||
var $list = this.$('ul.o_followers_list'); |
|||
if (dialog) { |
|||
$list = this.dialog.$('ul'); |
|||
} |
|||
$list.empty(); |
|||
this._super(data, id, dialog); |
|||
$list.find('input[type=checkbox]').change(function() |
|||
{ |
|||
$list.find('input[type=checkbox]').change(function() { |
|||
$list.find(_.str.sprintf( |
|||
'#custom_notification_%s%s', |
|||
jQuery(this).data('id'), |
|||
dialog ? '_dialog' : '' |
|||
)) |
|||
.toggle(jQuery(this).prop('checked')); |
|||
)).toggle(jQuery(this).prop('checked')); |
|||
}); |
|||
if(!dialog) |
|||
{ |
|||
$list.find('.oe_custom_notification input[type=radio]') |
|||
.change(this.proxy('do_update_subscription')); |
|||
}; |
|||
}, |
|||
do_update_subscription: function(event, user_pid) |
|||
{ |
|||
/* |
|||
if(jQuery(event.currentTarget).parents('.oe_custom_notification') |
|||
.length) |
|||
{ |
|||
// mail reacts on all inputs, suppress for our inputs
|
|||
return jQuery.when(); |
|||
if (!dialog) { |
|||
$list.find( |
|||
'.oe_custom_notification input[type=radio]' |
|||
).change(this.proxy('do_update_subscription')); |
|||
} |
|||
*/ |
|||
}, |
|||
/* eslint-disable-next-line no-unused-vars */ |
|||
do_update_subscription: function (event, follower_id, is_channel) { |
|||
var self = this, |
|||
update_func = 'message_custom_notification_update_user', |
|||
follower_ids = [this.session.uid], |
|||
custom_notifications = {}, |
|||
oe_action = this.$('.oe_actions'); |
|||
if(user_pid) |
|||
{ |
|||
$list = this.$('ul'); |
|||
if (follower_id !== undefined) { |
|||
update_func = 'message_custom_notification_update'; |
|||
follower_ids = [user_pid]; |
|||
oe_action = jQuery('.oe_edit_actions'); |
|||
follower_ids = [follower_id]; |
|||
$list = this.dialog.$('ul'); |
|||
} |
|||
_(follower_ids).each(function(follower) |
|||
{ |
|||
|
|||
_(follower_ids).each(function(follower) { |
|||
var follower_settings = custom_notifications[follower] = {}; |
|||
oe_action.find('.oe_custom_notification') |
|||
.each(function() |
|||
{ |
|||
var id = parseInt(jQuery(this).data('id')), |
|||
$list.find( |
|||
'.o_mail_follower_custom_notification' |
|||
).each(function () { |
|||
var id = parseInt(jQuery(this).data('id'), 10), |
|||
settings = follower_settings[id] = {}; |
|||
settings['force_mail'] = jQuery(this) |
|||
.find('.oe_custom_notification_mail input:checked') |
|||
settings.force_mail = jQuery(this) |
|||
.find('.mail input:checked') |
|||
.val(); |
|||
settings['force_own'] = jQuery(this) |
|||
.find('.oe_custom_notification_own input:checked') |
|||
settings.force_own = jQuery(this) |
|||
.find('.own input:checked') |
|||
.val(); |
|||
}); |
|||
}); |
|||
return jQuery.when(this._super.apply(this, arguments)) |
|||
.then(function() |
|||
{ |
|||
return jQuery.when( |
|||
this._super.apply(this, arguments) |
|||
).then(function () { |
|||
return self.ds_model.call( |
|||
update_func, |
|||
[[self.view.datarecord.id], custom_notifications]) |
|||
}) |
|||
[[self.view.datarecord.id], custom_notifications]); |
|||
}).then(this.proxy('render_value')); |
|||
}, |
|||
}); |
|||
} |
|||
}); |
@ -1,11 +1,9 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<openerp> |
|||
<data> |
|||
<odoo> |
|||
<template id="assets_backend" name="mail_follower_custom_notification assets" inherit_id="web.assets_backend"> |
|||
<xpath expr="." position="inside"> |
|||
<script type="text/javascript" src="/mail_follower_custom_notification/static/src/js/mail_follower_custom_notification.js"></script> |
|||
<link rel="stylesheet" href="/mail_follower_custom_notification/static/src/css/mail_follower_custom_notification.css"/> |
|||
</xpath> |
|||
</template> |
|||
</data> |
|||
</openerp> |
|||
</odoo> |
@ -1,4 +1,4 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2015 Therp BV <http://therp.nl> |
|||
# Copyright 2015 Therp BV <http://therp.nl> |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
from . import mail_subtype_assign_custom_notifications |
Write
Preview
Loading…
Cancel
Save
Reference in new issue