Added Upstream Patch for mail

This commit is contained in:
az-flectra 2018-07-19 17:19:58 +05:30
parent 5e19179427
commit b851be6ef5
3 changed files with 17 additions and 12 deletions

View File

@ -131,7 +131,6 @@ class MailMail(models.Model):
messages to send (by default all 'outgoing' messages to send (by default all 'outgoing'
messages are sent). messages are sent).
""" """
if not self.ids:
filters = ['&', filters = ['&',
('state', '=', 'outgoing'), ('state', '=', 'outgoing'),
'|', '|',
@ -140,7 +139,11 @@ class MailMail(models.Model):
if 'filters' in self._context: if 'filters' in self._context:
filters.extend(self._context['filters']) filters.extend(self._context['filters'])
# TODO: make limit configurable # TODO: make limit configurable
ids = self.search(filters, limit=10000).ids filtered_ids = self.search(filters, limit=10000).ids
if not ids:
ids = filtered_ids
else:
ids = list(set(filtered_ids) & set(ids))
res = None res = None
try: try:
# auto-commit except in testing mode # auto-commit except in testing mode

View File

@ -1732,6 +1732,8 @@ class MailThread(models.AbstractModel):
continue continue
if isinstance(content, pycompat.text_type): if isinstance(content, pycompat.text_type):
content = content.encode('utf-8') content = content.encode('utf-8')
elif content is None:
continue
data_attach = { data_attach = {
'name': name, 'name': name,
'datas': base64.b64encode(content), 'datas': base64.b64encode(content),
@ -1757,7 +1759,7 @@ class MailThread(models.AbstractModel):
if not attachment: if not attachment:
attachment = fname_mapping.get(node.get('data-filename'), '') attachment = fname_mapping.get(node.get('data-filename'), '')
if attachment: if attachment:
node.set('src', '/web/image/%s' % attachment.id) node.set('src', '/web/image/%s?access_token=%s' % (attachment.id, attachment.access_token))
postprocessed = True postprocessed = True
if postprocessed: if postprocessed:
body = lxml.html.tostring(root, pretty_print=False, encoding='UTF-8') body = lxml.html.tostring(root, pretty_print=False, encoding='UTF-8')

View File

@ -20,7 +20,7 @@
invisible="not context.get('mail_invite_follower_channel_only')" invisible="not context.get('mail_invite_follower_channel_only')"
options="{'no_create': True}"/> options="{'no_create': True}"/>
<field name="send_mail" invisible="context.get('mail_invite_follower_channel_only')"/> <field name="send_mail" invisible="context.get('mail_invite_follower_channel_only')"/>
<field name="message" attrs="{'invisible': [('send_mail','!=',True)]}" options="{'style-inline': true}" class="test_message"/> <field name="message" attrs="{'invisible': [('send_mail','!=',True)]}" options="{'style-inline': true, 'no-attachment': true}" class="test_message"/>
</group> </group>
<footer> <footer>
<button string="Add Followers" <button string="Add Followers"