Files
odoo_source/addons/test_mail/tests/common.py
T
mcm-odooandThibault Delavallée de1743ab12 [REF] mail, various: remove user_signature field from mail.template
RATIONALE

Mail template model holds a field telling odoo mail engine to automatically
add the current user's signature to the body. Its use depends on the use
case

  * using the template in the composer on a single record: it is displayed
    in the rendered template in the composer, meaning people could change it.
    This behavior is interesting as it allows to see the email content;
  * using the template in the composer in mass mail mode: it is not displayed
    as only the raw jinja is displayed. It is therefore not obvious that it
    will be appended to the body of the mail. People could add it manually and
    have 2 signatures as a result;

A mechanism automatically adding a signature to sent emails when posting a
message is already implemented and is based on template existence. If a
template has been used when posting, no signature is added in sent emails.
Otherwise it is automatically added. This behavior should not change.

Behavior will therefore be

  * use a template -> specify signature usage in it manually through jinja;
  * do not use a template -> signature added in sent emails;

SPECIFICATIONS

Remove user_signature.

Update template body accordingly. In customer oriented templates that are using
it and do not already contain it, manually add a call to user.signature within
the jinja code. When set to False, just remove its declaration.

Quickly clean some signature integration.

LINKS

Task ID 2089252
Community PR odoo/odoo#39482
Enterprise PR odoo/enterprise#6459
Upgrade PR odoo/upgrate#761

Related: odoo/enterprise#6459
Related: odoo/upgrade#761
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Co-authored-by: Michaël Mattiello <mcm@odoo.com>
Co-authored-by: Thibault Delavallée <tde@odoo.com>
2020-02-11 14:01:13 +00:00

93 lines
3.3 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.addons.mail.tests import common as mail_common
from odoo.tests import common
mail_new_test_user = mail_common.mail_new_test_user
class TestMailCommon(common.SavepointCase, mail_common.MailCase):
@classmethod
def setUpClass(cls):
super(TestMailCommon, cls).setUpClass()
# give default values for all email aliases and domain
cls._init_mail_gateway()
# ensure admin configuration
cls.user_admin = cls.env.ref('base.user_admin')
cls.user_admin.write({'notification_type': 'inbox'})
cls.partner_admin = cls.env.ref('base.partner_admin')
cls.company_admin = cls.user_admin.company_id
cls.company_admin.write({'email': 'company@example.com'})
# test standard employee
cls.user_employee = mail_new_test_user(
cls.env, login='employee', groups='base.group_user', company_id=cls.company_admin.id,
name='Ernest Employee', notification_type='inbox', signature='--\nErnest')
cls.partner_employee = cls.user_employee.partner_id
@classmethod
def _create_channel_listener(cls):
cls.channel_listen = cls.env['mail.channel'].with_context(cls._test_context).create({'name': 'Listener'})
@classmethod
def _create_portal_user(cls):
cls.user_portal = mail_new_test_user(
cls.env, login='portal_test', groups='base.group_portal', company_id=cls.company_admin.id,
name='Chell Gladys', notification_type='email')
cls.partner_portal = cls.user_portal.partner_id
return cls.user_portal
@classmethod
def _create_template(cls, model, template_values=None):
create_values = {
'name': 'TestTemplate',
'subject': 'About ${object.name}',
'body_html': '<p>Hello ${object.name}</p>',
'model_id': cls.env['ir.model']._get(model).id,
}
if template_values:
create_values.update(template_values)
cls.email_template = cls.env['mail.template'].create(create_values)
return cls.email_template
def flush_tracking(self):
""" Force the creation of tracking values. """
self.env['base'].flush()
self.cr.precommit()
class TestMailMultiCompanyCommon(TestMailCommon):
@classmethod
def setUpClass(cls):
super(TestMailMultiCompanyCommon, cls).setUpClass()
cls.company_2 = cls.env['res.company'].create({
'name': 'Second Test Company',
})
class TestRecipients(common.SavepointCase):
@classmethod
def setUpClass(cls):
super(TestRecipients, cls).setUpClass()
Partner = cls.env['res.partner'].with_context({
'mail_create_nolog': True,
'mail_create_nosubscribe': True,
'mail_notrack': True,
'no_reset_password': True,
})
cls.partner_1 = Partner.create({
'name': 'Valid Lelitre',
'email': 'valid.lelitre@agrolait.com',
'country_id': cls.env.ref('base.be').id,
'mobile': '0456001122',
})
cls.partner_2 = Partner.create({
'name': 'Valid Poilvache',
'email': 'valid.other@gmail.com',
'country_id': cls.env.ref('base.be').id,
'mobile': '+32 456 22 11 00',
})