-
-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
10.0 mail private add channels #182
10.0 mail private add channels #182
Conversation
1c48b2e
to
44f0d3c
Compare
aa38c5a
to
f8a26ed
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My comments from #183 (review) can be applied here too
f8a26ed
to
a6896a8
Compare
I corrected it |
@@ -1,10 +1,13 @@ | |||
# -*- coding: utf-8 -*- | |||
# Copyright 2018 Ruslan Ronzhin <https://it-projects.info/team/rusllan/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Find all contributors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added other authors
mail_base/doc/changelog.rst
Outdated
@@ -1,3 +1,7 @@ | |||
`1.1.5` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1.1.0
mail_base/static/lib/base.js
Outdated
@@ -1,3 +1,6 @@ | |||
/* Copyright 2018 Ruslan Ronzhin <https://it-projects.info/team/rusllan/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copyrights are totally wrong
mail_private/__manifest__.py
Outdated
{ | ||
"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": "10.0.1.0.1", | ||
"version": "10.0.1.1.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
10.0.1.1.0
@@ -1,4 +1,9 @@ | |||
<?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> | |||
Copyright 2019 Artem Rafailov <https://it-projects.info/team/Ommo73/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you set yourself here if there are no any changes by you?
mail_base/static/lib/base.js
Outdated
get_checked_channels_ids: function () { | ||
var self = this; | ||
var checked_channels = []; | ||
this.$('.o_composer_suggested_partners:eq(1) input:checked').each(function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename or add a new class/id. It confuses, the method is about channels, but we looking through the partners
mail_base/static/lib/base.js
Outdated
// for module mail_private | ||
if (self.options.is_private) { | ||
message.context.is_private = true; | ||
message.context.channel_ids = self.get_checked_channels_ids(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try to find a way to do it like for partner_ids, not via context.
mail_base/static/lib/base.js
Outdated
@@ -177,6 +181,12 @@ var MailComposer = composer.BasicComposer.extend({ | |||
message.subtype = 'mail.mt_note'; | |||
} | |||
|
|||
// for module mail_private | |||
if (self.options.is_private) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure that it's needed here. Is there any reason for that? In 12v I remember was a function that redefines values to a new object without is_private attribute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any way to avoid updating mail_base?
mail_private/models.py
Outdated
# TDE CHECK: add partners / channels as arguments to be able to notify a message with / without computation ?? | ||
self.ensure_one() # tde: not sure, just for testinh, will see | ||
partners = self.env['res.partner'] | self.partner_ids | ||
channels = self.env['mail.channel'].search([('id', '=', self._context['channel_ids'])]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use 'browse' not search.
|
||
# TDE CHECK: add partners / channels as arguments to be able to notify a message with / without computation ?? | ||
self.ensure_one() # tde: not sure, just for testinh, will see | ||
partners = self.env['res.partner'] | self.partner_ids |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't understand this construction because
self.env['res.partner'] | self.partner_ids = self.partner_ids
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could someone explain?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can guess that self.partner_ids may be undefined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Empty self.partner_ids
is the same as self.env['res.partner']
.
Was this code copy-paster from odoo? If so, one can try to make a PR that fix this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yelizariev yes this code copy-paster from odoo
mail_private/models.py
Outdated
|
||
@api.multi | ||
def _notify_mail_private(self, force_send=False, send_after_commit=True, user_signature=True): | ||
""" Add the related record followers to the destination partner_ids if is not a private message. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, instead of this comment, it will be good to write a comment that the method was copy-pasted from odoo and describe the difference from the origin (and show where the code was changed)
124fd91
to
36e573a
Compare
36e573a
to
4655aa6
Compare
4655aa6
to
add565a
Compare
3650cc7
to
41bc443
Compare
|
||
if (options && options.is_private) { | ||
self.internal_users_ids = options.internal_ids |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing semicolon.
|
||
if (options && options.is_private) { | ||
self.internal_users_ids = options.internal_ids |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing semicolon semi
41bc443
to
1696029
Compare
mail_private/models.py
Outdated
'parent_id': parent_id, | ||
'subtype_id': subtype_id, | ||
'partner_ids': [(4, pid) for pid in partner_ids], | ||
'channel_ids': [(4, pid) for pid in kwargs['channel_ids']] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update kwargs at first and then call the super with updated kwargs. No need for copy-paste here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kwargs['channel_ids'] = [(4, pid) for pid in kwargs['channel_ids']]
super(MailThread, self).message_post(idk, kwargs)
mail_private/models.py
Outdated
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
continuation line under-indented for visual indent
mail_private/models.py
Outdated
content_subtype='html', **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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
continuation line under-indented for visual indent
mail_private/models.py
Outdated
# 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, exceptions, _, tools |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'odoo._' imported but unused
'odoo.exceptions' imported but unused
'odoo.tools' imported but unused
5dca30f
to
cc93723
Compare
@@ -52,13 +65,14 @@ Chatter.include({ | |||
open_composer: function (options) { | |||
var self = this; | |||
this._super.apply(this, arguments); | |||
if (options && options.is_private) { | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Artem, keep the commit history clean. Each PR you give me to check has this kind of problems. Use git diff
and check sent code here. 3 places need to be changed in this PR.
this.composer.options.is_private = options.is_private; | ||
|
||
_.each(self.recipients_for_internal_message, function (partner) { | ||
self.composer.suggested_partners.push({ | ||
checked: (partner.user_ids.length > 0), | ||
checked: (self.internal_users_ids.indexOf(partner.user_ids[0]) !== -1), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and again, why do you check only the first id? There might be several of them
|
||
// Fetch partner ids | ||
return new Model('mail.followers').call( | ||
'read', [follower_ids, ['channel_id']]).then(function (res_partners) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's about channels, not partners. Update all variable names in the function
} | ||
|
||
// for module mail_private | ||
if (self.options.is_private) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can do it without a total method redefinition
1004659
to
ef59080
Compare
this.composer.options.is_private = options.is_private; | ||
|
||
_.each(self.recipients_for_internal_message, function (partner) { | ||
self.composer.suggested_partners.push({ | ||
checked: (partner.user_ids.length > 0), | ||
checked: (self.internal_users_ids.some(r=> partner.user_ids.includes(r))), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'arrow function syntax (=>)' is only available in ES6 (use 'esversion: 6').
this.composer.options.is_private = options.is_private; | ||
|
||
_.each(self.recipients_for_internal_message, function (partner) { | ||
self.composer.suggested_partners.push({ | ||
checked: (partner.user_ids.length > 0), | ||
checked: (self.internal_users_ids.some(r=> partner.user_ids.includes(r))), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expected parentheses around arrow function argument arrow-parens
b8db881
to
00a0127
Compare
if (self.options.is_private) { | ||
self.context.is_private = true; | ||
} | ||
return this._super() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing semicolon.
if (self.options.is_private) { | ||
self.context.is_private = true; | ||
} | ||
return this._super() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing semicolon semi
00a0127
to
b45f5b7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change the button name to "Add Channels" in the pop-up window
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a message is sent to a task follower via "Send internal message" (for example, from demo to admin), it is noted in the task discussion, rather than being sent.
An error occurred when admin clicked "Send internal message" in this example, but it has not been reproduced.
This part of the interface does not apply to our module. |
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Messages sent to a channel via "Send internal message" do not appear on the Discuss dashboard.
And even messages sent via "New message" don't appear there after that if the page is not reloaded.
b6082ce
to
d9cd643
Compare
}); | ||
}); | ||
return checked_channels; | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expected an assignment or function call and instead saw an expression.
Expected an identifier and instead saw ','.
Missing semicolon.
return this.users_ids; | ||
}, | ||
|
||
get_checked_channels_ids: function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Label 'get_checked_channels_ids' on function statement.
Missing name in function declaration.
return users_ids; | ||
}); | ||
return this.users_ids; | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expected an assignment or function call and instead saw an expression.
Expected an identifier and instead saw ','.
Missing semicolon.
}); | ||
}, | ||
|
||
get_internal_users_ids: function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Label 'get_internal_users_ids' on function statement.
Missing name in function declaration.
}); | ||
}); | ||
}); | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expected an assignment or function call and instead saw an expression.
Expected an identifier and instead saw ','.
Missing semicolon.
} | ||
}, | ||
|
||
get_channels_for_internal_message: function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Label 'get_channels_for_internal_message' on function statement.
Missing name in function declaration.
@@ -101,20 +124,86 @@ Chatter.include({ | |||
}); | |||
}); | |||
}); | |||
} | |||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expected an assignment or function call and instead saw an expression.
Expected an identifier and instead saw ','.
Missing semicolon.
@@ -33,32 +41,38 @@ Chatter.include({ | |||
}).fail(function () { | |||
// todo: display notification | |||
}); | |||
}, | |||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expected an assignment or function call and instead saw an expression.
Expected an identifier and instead saw ','.
Missing semicolon.
d9cd643
to
843c7dd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why there are two commits with the same message?
It's because mail_private module refers to the mail_base module. I add one new function that is in the commit message, but changes occur in two modules. |
Fix this lint please:
|
843c7dd
to
1ccc657
Compare
I approve to merge it now |
Approved by @yelizariev |
Added ability to select channels for private message sending