[12.0][MIG] mail_usability
This commit is contained in:
committed by
Alexis de Lattre
parent
70d7cbdfda
commit
f752fbc9f3
@@ -1,4 +1,2 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
from . import models
|
from . import models
|
||||||
from . import wizard
|
from . import wizard
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# Copyright 2020 Akretion France (http://www.akretion.com)
|
||||||
# © 2016 Akretion (http://www.akretion.com)
|
|
||||||
# @author Benoît Guillot <benoit.guillot@akretion.com>
|
# @author Benoît Guillot <benoit.guillot@akretion.com>
|
||||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
{
|
{
|
||||||
'name': 'Mail Usability',
|
'name': 'Mail Usability',
|
||||||
'version': '10.0.1.0.0',
|
'version': '12.0.1.0.0',
|
||||||
'category': 'Base',
|
'category': 'Base',
|
||||||
'license': 'AGPL-3',
|
'license': 'AGPL-3',
|
||||||
'summary': 'Usability improvements on mails',
|
'summary': 'Usability improvements on mails',
|
||||||
@@ -29,6 +28,6 @@ Small usability improvements on mails:
|
|||||||
'views/mail_view.xml',
|
'views/mail_view.xml',
|
||||||
'data/mail_data.xml',
|
'data/mail_data.xml',
|
||||||
'wizard/email_template_preview_view.xml',
|
'wizard/email_template_preview_view.xml',
|
||||||
],
|
],
|
||||||
'installable': True,
|
'installable': True,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<odoo>
|
<odoo noupdate="1">
|
||||||
<data noupdate="1">
|
|
||||||
|
|
||||||
<!--Default Notification Email template -->
|
<!--Default Notification Email template -->
|
||||||
<record id="mail_template_notification" model="mail.template">
|
<record id="mail_template_notification" model="mail.template">
|
||||||
@@ -11,5 +10,4 @@
|
|||||||
<field name="body_html">${object.body | safe}</field>
|
<field name="body_html">${object.body | safe}</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
</data>
|
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
from . import mail
|
from . import mail
|
||||||
from . import tools
|
from . import tools
|
||||||
from . import mail_template
|
from . import mail_template
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# Copyright 2016-2017 Akretion France (http://www.akretion.com)
|
||||||
# Copyright (C) 2016-2017 Akretion (http://www.akretion.com)
|
|
||||||
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
@@ -31,9 +30,7 @@ class MailThread(models.AbstractModel):
|
|||||||
if not 'mail_create_nosubscribe' in self._context:
|
if not 'mail_create_nosubscribe' in self._context:
|
||||||
# Do not implicitly follow an object by just sending a message
|
# Do not implicitly follow an object by just sending a message
|
||||||
self = self.with_context(mail_create_nosubscribe=True)
|
self = self.with_context(mail_create_nosubscribe=True)
|
||||||
return super(MailThread,
|
return super(MailThread, self).message_post(
|
||||||
self.with_context(mail_create_nosubscribe=True)
|
body=body, subject=subject, message_type=message_type,
|
||||||
).message_post(
|
subtype=subtype, parent_id=parent_id, attachments=attachments,
|
||||||
body=body, subject=subject, message_type=message_type,
|
content_subtype=content_subtype, **kwargs)
|
||||||
subtype=subtype, parent_id=parent_id, attachments=attachments,
|
|
||||||
content_subtype=content_subtype, **kwargs)
|
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# Copyright 2019 Akretion France (http://www.akretion.com)
|
||||||
# Copyright 2019 Akretion (http://www.akretion.com).
|
|
||||||
# @author Sébastien BEAU <sebastien.beau@akretion.com>
|
# @author Sébastien BEAU <sebastien.beau@akretion.com>
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
from openerp import api, fields, models
|
from odoo import models
|
||||||
|
|
||||||
|
|
||||||
class MailMessage(models.Model):
|
class MailMessage(models.Model):
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# Copyright 2018 Akretion France (http://www.akretion.com)
|
||||||
# Copyright 2018 Akretion (http://www.akretion.com).
|
|
||||||
# @author Sébastien BEAU <sebastien.beau@akretion.com>
|
# @author Sébastien BEAU <sebastien.beau@akretion.com>
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
|||||||
@@ -1,52 +1,28 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# Copyright 2016-2019 Akretion France (http://www.akretion.com)
|
||||||
# Copyright (C) 2016-2019 Akretion (http://www.akretion.com)
|
|
||||||
# @author Sébastien BEAU <sebastien.beau@akretion.com>
|
# @author Sébastien BEAU <sebastien.beau@akretion.com>
|
||||||
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
from odoo import models, fields
|
from odoo import models, fields, api
|
||||||
|
|
||||||
|
|
||||||
class ResPartner(models.Model):
|
class ResPartner(models.Model):
|
||||||
_inherit = 'res.partner'
|
_inherit = 'res.partner'
|
||||||
|
|
||||||
notify_email = fields.Selection(
|
|
||||||
selection_add=[
|
|
||||||
('all_except_notification', 'All Messages Except Notifications')],
|
|
||||||
default='all_except_notification')
|
|
||||||
opt_out = fields.Boolean(track_visibility='onchange')
|
opt_out = fields.Boolean(track_visibility='onchange')
|
||||||
|
|
||||||
def _should_be_notify_by_email(self, message):
|
@api.model
|
||||||
if message.message_type == 'notification':
|
def _notify(self, message, rdata, record, force_send=False,
|
||||||
if self.notify_email == 'always':
|
send_after_commit=True, model_description=False,
|
||||||
return True
|
mail_auto_delete=True):
|
||||||
else:
|
# use an empty layout for notification by default
|
||||||
return False
|
|
||||||
else:
|
|
||||||
return True
|
|
||||||
|
|
||||||
def _notify_by_email(
|
|
||||||
self, message, force_send=False, send_after_commit=True,
|
|
||||||
user_signature=True):
|
|
||||||
|
|
||||||
# use an empty layout for notification by default
|
|
||||||
if not self._context.get('custom_layout'):
|
if not self._context.get('custom_layout'):
|
||||||
self = self.with_context(
|
self = self.with_context(
|
||||||
custom_layout='mail_usability.mail_template_notification')
|
custom_layout='mail_usability.mail_template_notification')
|
||||||
|
|
||||||
# Filter the partner that should receive the notification
|
|
||||||
filtered_partners = self.filtered(
|
|
||||||
lambda p: p._should_be_notify_by_email(message)
|
|
||||||
)
|
|
||||||
|
|
||||||
return super(ResPartner, filtered_partners)._notify_by_email(
|
|
||||||
message, force_send=force_send,
|
|
||||||
send_after_commit=send_after_commit,
|
|
||||||
user_signature=user_signature)
|
|
||||||
|
|
||||||
def _notify_prepare_email_values(self, message):
|
|
||||||
res = super(ResPartner, self)._notify_prepare_email_values(message)
|
|
||||||
# Never auto delete notification email
|
# Never auto delete notification email
|
||||||
# fucking to hard to debug when message have been delete
|
# fucking to hard to debug when message have been delete
|
||||||
res['auto_delete'] = False
|
mail_auto_delete = False
|
||||||
return res
|
return super(ResPartner, self)._notify(
|
||||||
|
message=message, rdata=rdata, record=record,
|
||||||
|
force_send=force_send, send_after_commit=send_after_commit,
|
||||||
|
model_description=model_description, mail_auto_delete=mail_auto_delete)
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# Copyright 2018 Akretion France (http://www.akretion.com)
|
||||||
# Copyright 2018 Akretion (http://www.akretion.com).
|
|
||||||
# @author Sébastien BEAU <sebastien.beau@akretion.com>
|
# @author Sébastien BEAU <sebastien.beau@akretion.com>
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
@@ -41,5 +40,4 @@ if os.getenv('LOG_STYLE_SANITIZE'):
|
|||||||
for (key, val) in valid_styles.iteritems())
|
for (key, val) in valid_styles.iteritems())
|
||||||
else:
|
else:
|
||||||
del el.attrib['style']
|
del el.attrib['style']
|
||||||
import pdb; pdb.set_trace()
|
|
||||||
_Cleaner.parse_style = parse_style
|
_Cleaner.parse_style = parse_style
|
||||||
|
|||||||
@@ -1,21 +1,16 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!--
|
|
||||||
© 2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
|
||||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
||||||
-->
|
|
||||||
|
|
||||||
<odoo>
|
<odoo>
|
||||||
|
|
||||||
<record id="view_mail_tree" model="ir.ui.view">
|
<record id="view_mail_tree" model="ir.ui.view">
|
||||||
<field name="model">mail.mail</field>
|
<field name="model">mail.mail</field>
|
||||||
<field name="inherit_id" ref="mail.view_mail_tree"/>
|
<field name="inherit_id" ref="mail.view_mail_tree"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<field name="email_from" position="replace"/>
|
<field name="email_from" position="replace"/>
|
||||||
<field name="date" position="after">
|
<field name="date" position="after">
|
||||||
<field name="email_from"/>
|
<field name="email_from"/>
|
||||||
<field name="email_to"/>
|
<field name="email_to"/>
|
||||||
|
</field>
|
||||||
</field>
|
</field>
|
||||||
</field>
|
</record>
|
||||||
</record>
|
|
||||||
|
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|||||||
@@ -1,3 +1 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
from . import email_template_preview
|
from . import email_template_preview
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# Copyright 2019 Akretion France (http://www.akretion.com)
|
||||||
# Copyright 2019 Akretion (http://www.akretion.com).
|
|
||||||
# @author Sébastien BEAU <sebastien.beau@akretion.com>
|
# @author Sébastien BEAU <sebastien.beau@akretion.com>
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
@@ -26,10 +25,10 @@ class TemplatePreview(models.TransientModel):
|
|||||||
model = self.env['ir.model'].browse(result['model_id'])
|
model = self.env['ir.model'].browse(result['model_id'])
|
||||||
return [(model.model, model.name)]
|
return [(model.model, model.name)]
|
||||||
else:
|
else:
|
||||||
models = self.env['ir.model'].search([('state', '!=', 'manual')])
|
ir_models = self.env['ir.model'].search([('state', '!=', 'manual')])
|
||||||
return [(model.model, model.name)
|
return [(ir_model.model, ir_model.name)
|
||||||
for model in models
|
for ir_model in ir_models
|
||||||
if not model.model.startswith('ir.')]
|
if not ir_model.model.startswith('ir.')]
|
||||||
|
|
||||||
@api.depends('object_id')
|
@api.depends('object_id')
|
||||||
def _compute_res_id(self):
|
def _compute_res_id(self):
|
||||||
|
|||||||
@@ -1,24 +1,24 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<odoo>
|
<odoo>
|
||||||
|
|
||||||
<record id="email_template_preview_form" model="ir.ui.view">
|
<record id="email_template_preview_form" model="ir.ui.view">
|
||||||
<field name="model">email_template.preview</field>
|
<field name="model">email_template.preview</field>
|
||||||
<field name="inherit_id" ref="mail.email_template_preview_form"/>
|
<field name="inherit_id" ref="mail.email_template_preview_form"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<field name="res_id" position="attributes">
|
<field name="res_id" position="attributes">
|
||||||
<attribute name="invisible">True</attribute>
|
<attribute name="invisible">True</attribute>
|
||||||
|
</field>
|
||||||
|
<field name="res_id" position="after">
|
||||||
|
<field name="object_id"/>
|
||||||
|
</field>
|
||||||
|
<footer position="inside">
|
||||||
|
<button
|
||||||
|
string="Send"
|
||||||
|
name="send"
|
||||||
|
class="btn-primary"
|
||||||
|
type='object'/>
|
||||||
|
</footer>
|
||||||
</field>
|
</field>
|
||||||
<field name="res_id" position="after">
|
</record>
|
||||||
<field name="object_id"/>
|
|
||||||
</field>
|
|
||||||
<footer position="inside">
|
|
||||||
<button
|
|
||||||
string="Send"
|
|
||||||
name="send"
|
|
||||||
class="btn-primary"
|
|
||||||
type='object'/>
|
|
||||||
</footer>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|||||||
Reference in New Issue
Block a user