Skip to content

Commit

Permalink
Merge pull request #235 from Ommo73/11.0-mail_addons-merge2
Browse files Browse the repository at this point in the history
  • Loading branch information
itpp-bot authored Oct 25, 2019
2 parents cc429a5 + 1914b4a commit 0407ce3
Show file tree
Hide file tree
Showing 36 changed files with 285 additions and 100 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ env:
matrix:
- LINT_CHECK="1"
- CHECK_TAGS="1"
- TESTS="1" ODOO_REPO="odoo/odoo" MAKEPOT="1"
- TESTS="1" ODOO_REPO="odoo/odoo"
- MAKEPOT="1"
- TESTS="1" ODOO_REPO="OCA/OCB"

install:
Expand Down
2 changes: 1 addition & 1 deletion mail_base/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* fixes toggling left bar
* fixes Recipients field. Out-of-box this field could be empty.

One can say, that the module do this todo from `addons/mail/static/src/js/chat_manager.js <https://github.com/odoo/odoo/blob/9.0/addons/mail/static/src/js/chat_manager.js#L57>`__
One can say, that the module do this todo from `addons/mail/static/src/js/chat_manager.js <https://github.com/odoo/odoo/blob/11.0/addons/mail/static/src/js/chat_manager.js#L57>`__

// to do: move this to mail.utils

Expand Down
1 change: 1 addition & 0 deletions mail_base/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html)

from . import models
from . import controllers
6 changes: 5 additions & 1 deletion mail_base/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# Copyright 2016 x620 <https://github.com/x620>
# Copyright 2018 Ruslan Ronzhin <https://it-projects.info/team/rusllan/>
# Copyright 2016-2019 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
# License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html)
{
"name": "Mail Base",
"summary": """Makes Mail extendable""",
"category": "Discuss",
"images": [],
"version": "11.0.1.0.5",
"version": "11.0.1.1.0",

"author": "IT-Projects LLC, Pavel Romanchenko",
"support": "[email protected]",
Expand Down
3 changes: 3 additions & 0 deletions mail_base/controllers/main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2017 mikaelh <https://github.com/mikaelh>
# Copyright 2017-2019 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
# License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html)
from openerp.http import request
from openerp.addons.bus.controllers.main import BusController

Expand Down
4 changes: 4 additions & 0 deletions mail_base/doc/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
`1.1.0`
-------
- **New**: added ability to select channels for private message sending.

`1.0.5`
-------
**FIX**: polling errors on heavy server load
Expand Down
7 changes: 5 additions & 2 deletions mail_base/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2016 x620 <https://github.com/x620>
# Copyright 2017 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
# License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html)

from openerp import api, models

Expand All @@ -12,8 +15,8 @@ def write(self, values):
values['partner_ids'] = []
for triplet in values.get('needaction_partner_ids'):
if triplet[0] == 6:
for id in triplet[2]:
values['partner_ids'].append((4, id, False))
for i in triplet[2]:
values['partner_ids'].append((4, i, False))
return super(MailMessage, self).write(values)


Expand Down
3 changes: 3 additions & 0 deletions mail_base/static/lib/base.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/* Copyright 2017 Artyom Losev <https://github.com/ArtyomLosev>
Copyright 2019 Artem Rafailov <https://github.com/Ommo73>
License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html). */
odoo.define('mail_base.base', function (require) {
"use strict";

Expand Down
6 changes: 3 additions & 3 deletions mail_multi_website/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
:target: https://www.gnu.org/licenses/lgpl
:alt: License: LGPL-3

===========================================
Email Addresses and Templates per Website
===========================================
=====================
Multi-Brand Mailing
=====================

Mail-related stuff for multi-website support

Expand Down
2 changes: 1 addition & 1 deletion mail_multi_website/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright 2018 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
{
"name": """Email Addresses and Templates per Website""",
"name": """Multi-Brand Mailing""",
"summary": """Use single Backend to manage several Websites""",
"category": "Discuss",
# "live_test_url": "http://apps.it-projects.info/shop/product/website-multi-company?version=11.0",
Expand Down
6 changes: 3 additions & 3 deletions mail_multi_website/doc/index.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
===========================================
Email Addresses and Templates per Website
===========================================
=====================
Multi-Brand Mailing
=====================

Installation
============
Expand Down
2 changes: 1 addition & 1 deletion mail_multi_website/static/description/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<section class="oe_container">
<div class="oe_row oe_spaced">
<div class="oe_span12">
<h2 class="oe_slogan" style="color:#875A7B;">Email Addresses and Templates per Website
<h2 class="oe_slogan" style="color:#875A7B;">Multi-Brand Mailing
</h2>
<h3 class="oe_slogan">Use single Backend to manage several Websites</h3>
</div>
Expand Down
1 change: 1 addition & 0 deletions mail_private/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html)

from . import models
10 changes: 9 additions & 1 deletion mail_private/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
# Copyright 2016 x620 <https://github.com/x620>
# Copyright 2016 Ilmir Karamov <https://it-projects.info/team/ilmir-k>
# Copyright 2016 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
# Copyright 2017 Artyom Losev <https://github.com/ArtyomLosev>
# Copyright 2018 Ruslan Ronzhin <https://it-projects.info/team/rusllan/>
# Copyright 2018 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
# Copyright 2019 Artem Rafailov <https://it-projects.info/team/Ommo73/>
# License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html).
{
"name": """Internal Messaging""",
"summary": """Send private messages to specified recipients, regardless of who are in followers list.""",
"category": "Discuss",
"images": ['images/mail_private_image.png'],
"version": "11.0.1.1.0",
"version": "11.0.1.2.0",
"application": False,

"author": "IT-Projects LLC, Pavel Romanchenko",
Expand Down
5 changes: 5 additions & 0 deletions mail_private/doc/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
`1.2.0`
-------

- **New**: added ability to select channels for private message sending.

`1.1.0`
-------

Expand Down
4 changes: 4 additions & 0 deletions mail_private/full_composer_wizard.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<!--Copyright 2017 Artyom Losev <https://github.com/ArtyomLosev>
Copyright 2018 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html).-->

<odoo>

<record model="ir.ui.view" id="email_compose_message_wizard_form_private">
Expand Down
15 changes: 10 additions & 5 deletions mail_private/i18n/mail_private.pot
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ msgstr ""
msgid "Dummy action"
msgstr ""

#. module: mail_private
#: model:ir.model,name:mail_private.model_mail_thread
msgid "Email Thread"
msgstr ""

#. module: mail_private
#: model:ir.model,name:mail_private.model_mail_compose_message
msgid "Email composition wizard"
Expand All @@ -60,7 +65,7 @@ msgstr ""

#. module: mail_private
#. openerp-web
#: code:addons/mail_private/static/src/xml/mail_private.xml:6
#: code:addons/mail_private/static/src/xml/mail_private.xml:12
#, python-format
msgid "Send a message to specified recipients only"
msgstr ""
Expand All @@ -75,21 +80,21 @@ msgstr ""

#. module: mail_private
#. openerp-web
#: code:addons/mail_private/static/src/xml/mail_private.xml:6
#: code:addons/mail_private/static/src/xml/mail_private.xml:12
#, python-format
msgid "Send internal message"
msgstr ""

#. module: mail_private
#. openerp-web
#: code:addons/mail_private/static/src/xml/mail_private.xml:12
#: code:addons/mail_private/static/src/xml/mail_private.xml:18
#, python-format
msgid "To: Followers of"
msgstr ""

#. module: mail_private
#. openerp-web
#: code:addons/mail_private/static/src/xml/mail_private.xml:23
#: code:addons/mail_private/static/src/xml/mail_private.xml:39
#, python-format
msgid "Uncheck all"
msgstr ""
Expand All @@ -110,7 +115,7 @@ msgstr ""

#. module: mail_private
#. openerp-web
#: code:addons/mail_private/static/src/xml/mail_private.xml:17
#: code:addons/mail_private/static/src/xml/mail_private.xml:23
#, python-format
msgid "this document"
msgstr ""
Expand Down
58 changes: 31 additions & 27 deletions mail_private/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Copyright 2016 x620 <https://github.com/x620>
# Copyright 2016 manawi <https://github.com/manawi>
# Copyright 2017 Artyom Losev <https://github.com/ArtyomLosev>
# Copyright 2019 Artem Rafailov <https://it-projects.info/team/Ommo73/>
# License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html).

from odoo import models, fields, api


Expand All @@ -13,32 +19,31 @@ class MailMessage(models.Model):
is_private = fields.Boolean(string='Send Internal Message')

def send_recepients_for_internal_message(self, model, domain):
result = []
result = {'partners': [], 'channels': []}
default_resource = self.env[model].search(domain)
follower_ids = default_resource.message_follower_ids
internal_ids = self.get_internal_users_ids()

recipient_ids = [r.partner_id for r in follower_ids if r.partner_id]
# channel_ids = [c.channel_id for c in follower_ids if c.channel_id]
channel_ids = [c.channel_id for c in follower_ids if c.channel_id]

for recipient in recipient_ids:
result.append({
'checked': recipient.user_ids.id in internal_ids,
result['partners'].append({
'checked': recipient.user_ids.id and not any(recipient.user_ids.mapped('share')),
'partner_id': recipient.id,
'full_name': recipient.name,
'name': recipient.name,
'email_address': recipient.email,
'reason': 'Recipient'
})

# for channel in channel_ids:
# result.append({
# 'checked': True,
# 'channel_id': channel.id,
# 'full_name': channel,
# 'name': '# '+channel.name,
# 'reason': 'Channel',
# })
for channel in channel_ids:
result['channels'].append({
'checked': True,
'channel_id': channel.id,
'full_name': channel.name,
'name': '# '+channel.name,
'reason': 'Channel',
})
return result

@api.multi
Expand All @@ -54,24 +59,13 @@ def _notify_mail_private(self, force_send=False, send_after_commit=True, user_si
""" Compute recipients to notify based on specified recipients and document
followers. Delegate notification to partners to send emails and bus notifications
and to channels to broadcast messages on channels """
group_user = self.env.ref('base.group_user')
# have a sudoed copy to manipulate partners (public can go here with website modules like forum / blog / ... )
self_sudo = self.sudo()

self.ensure_one()
partners_sudo = self_sudo.partner_ids
channels_sudo = self_sudo.channel_ids

if self_sudo.subtype_id and self.model and self.res_id:
followers = self_sudo.env['mail.followers'].search([
('res_model', '=', self.model),
('res_id', '=', self.res_id),
('subtype_ids', 'in', self_sudo.subtype_id.id),
])
if self_sudo.subtype_id.internal:
followers = followers.filtered(lambda fol: fol.channel_id or (fol.partner_id.user_ids and group_user in fol.partner_id.user_ids[0].mapped('groups_id')))
channels_sudo |= followers.mapped('channel_id')

# remove author from notified partners
if not self._context.get('mail_notify_author', False) and self_sudo.author_id:
partners_sudo = partners_sudo - self_sudo.author_id
Expand Down Expand Up @@ -108,6 +102,16 @@ def _notify_mail_private(self, force_send=False, send_after_commit=True, user_si

return True

def get_internal_users_ids(self):
internal_users_ids = self.env['res.users'].search([('share', '=', False)]).ids
return internal_users_ids

class MailThread(models.AbstractModel):
_inherit = 'mail.thread'

@api.multi
@api.returns('self', lambda value: value.id)
def message_post(self, body='', subject=None, message_type='notification', subtype=None, parent_id=False,
attachments=None, content_subtype='html', **kwargs):
if 'channel_ids' in kwargs:
kwargs['channel_ids'] = [(4, pid) for pid in kwargs['channel_ids']]
return super(MailThread, self).message_post(body, subject, message_type,
subtype, parent_id, attachments,
content_subtype, **kwargs)
10 changes: 10 additions & 0 deletions mail_private/static/src/css/mail_private.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.o_composer_suggested_channels{
margin-top: -5px;
}

.oe_composer_uncheck{
float: bottom;
margin-top:5px;
margin-left:-5px;
}

Loading

0 comments on commit 0407ce3

Please sign in to comment.