[MOV] (test_)mail: move tests into their dedicated module
Purpose: avoid having useless tables for test models in a production environment.
This commit is contained in:
@@ -3,4 +3,3 @@
|
||||
from . import models
|
||||
from . import wizard
|
||||
from . import controllers
|
||||
from .tests import models
|
||||
|
||||
@@ -33,16 +33,6 @@ access_mail_template,mail.template,model_mail_template,base.group_user,1,1,1,0
|
||||
access_mail_template_system,mail.template_system,model_mail_template,base.group_system,1,1,1,1
|
||||
access_mail_shortcode,mail.shortcode,model_mail_shortcode,base.group_user,1,1,1,1
|
||||
access_mail_shortcode_portal,mail.shortcode.portal,model_mail_shortcode,base.group_portal,1,0,0,0
|
||||
access_mail_test_simple_portal,mail.test.simple.portal,model_mail_test_simple,base.group_portal,1,0,0,0
|
||||
access_mail_test_simple_user,mail.test.simple.user,model_mail_test_simple,base.group_user,1,1,1,1
|
||||
access_mail_test_track_portal,mail.test.track.portal,model_mail_test_track,base.group_portal,0,0,0,0
|
||||
access_mail_test_track_user,mail.test.track.user.employee,model_mail_test_track,base.group_user,1,1,1,1
|
||||
access_mail_test_activity_portal,mail.test.activity.portal,model_mail_test_activity,base.group_portal,1,0,0,0
|
||||
access_mail_test_activity_user,mail.test.activity.user,model_mail_test_activity,base.group_user,1,1,1,1
|
||||
access_mail_test_full_portal,mail.test.full.portal,model_mail_test_full,base.group_portal,0,0,0,0
|
||||
access_mail_test_full_user,mail.test.full.user,model_mail_test_full,base.group_user,1,1,1,1
|
||||
access_mail_test_portal,mail.test.portal,model_mail_test,base.group_portal,1,1,0,0
|
||||
access_mail_test_user,mail.test.user,model_mail_test,base.group_user,1,1,1,1
|
||||
access_mail_activity_all,mail.activity.all,model_mail_activity,,0,0,0,0
|
||||
access_mail_activity_user,mail.activity.user,model_mail_activity,base.group_user,1,1,1,1
|
||||
access_mail_activity_type_all,mail.activity.type.all,model_mail_activity_type,,0,0,0,0
|
||||
|
||||
|
@@ -1,15 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import test_mail_activity
|
||||
from . import test_mail_followers
|
||||
from . import test_mail_message
|
||||
from . import test_mail_mail
|
||||
from . import test_mail_channel
|
||||
from . import test_mail_gateway
|
||||
from . import test_mail_template
|
||||
from . import test_message_compose
|
||||
from . import test_message_track
|
||||
from . import test_invite
|
||||
from . import test_ir_actions
|
||||
from . import test_update_notification
|
||||
from . import test_discuss
|
||||
@@ -1,3 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import test_mail_models
|
||||
@@ -1,97 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class MailTestSimple(models.Model):
|
||||
""" A very simple model only inheriting from mail.thread when only
|
||||
communication history is necessary. """
|
||||
_description = 'Simple Chatter Model'
|
||||
_name = 'mail.test.simple'
|
||||
_inherit = ['mail.thread']
|
||||
|
||||
name = fields.Char()
|
||||
email_from = fields.Char()
|
||||
|
||||
|
||||
class MailTestStandard(models.Model):
|
||||
""" This model can be used in tests when automatic subscription and simple
|
||||
tracking is necessary. Most features are present in a simple way. """
|
||||
_description = 'Standard Chatter Model'
|
||||
_name = 'mail.test.track'
|
||||
_inherit = ['mail.thread']
|
||||
|
||||
name = fields.Char()
|
||||
email_from = fields.Char()
|
||||
user_id = fields.Many2one('res.users', 'Responsible', track_visibility='onchange')
|
||||
umbrella_id = fields.Many2one('mail.test', track_visibility='onchange')
|
||||
|
||||
|
||||
class MailTestActivity(models.Model):
|
||||
""" This model can be used to test activities in addition to simple chatter
|
||||
features. """
|
||||
_description = 'Activity Model'
|
||||
_name = 'mail.test.activity'
|
||||
_inherit = ['mail.thread', 'mail.activity.mixin']
|
||||
|
||||
name = fields.Char()
|
||||
email_from = fields.Char()
|
||||
|
||||
|
||||
class MailTestFull(models.Model):
|
||||
""" This model can be used in tests when complex chatter features are
|
||||
required like modeling tasks or tickets. """
|
||||
_description = 'Full Chatter Model'
|
||||
_name = 'mail.test.full'
|
||||
_inherit = ['mail.thread']
|
||||
|
||||
name = fields.Char()
|
||||
email_from = fields.Char(track_visibility='always')
|
||||
count = fields.Integer(default=1)
|
||||
datetime = fields.Datetime(default=fields.Datetime.now)
|
||||
mail_template = fields.Many2one('mail.template', 'Template')
|
||||
customer_id = fields.Many2one('res.partner', 'Customer', track_visibility='onchange')
|
||||
user_id = fields.Many2one('res.users', 'Responsible', track_visibility='onchange')
|
||||
umbrella_id = fields.Many2one('mail.test', track_visibility='onchange')
|
||||
|
||||
def _track_template(self, tracking):
|
||||
res = super(MailTestFull, self)._track_template(tracking)
|
||||
record = self[0]
|
||||
changes, tracking_value_ids = tracking[record.id]
|
||||
if 'customer_id' in changes and record.mail_template:
|
||||
res['customer_id'] = (record.mail_template, {'composition_mode': 'mass_mail'})
|
||||
elif 'datetime' in changes:
|
||||
res['datetime'] = ('mail.track_template', {'composition_mode': 'mass_mail'})
|
||||
return res
|
||||
|
||||
def _track_subtype(self, init_values):
|
||||
self.ensure_one()
|
||||
if 'umbrella_id' in init_values and self.umbrella_id:
|
||||
return 'mail.track_subtype_umbrella'
|
||||
return super(MailTestFull, self)._track_subtype(init_values)
|
||||
|
||||
|
||||
class MailTestAlias(models.Model):
|
||||
""" This model can be used in tests when umbrella records like projects
|
||||
or teams are required. """
|
||||
_description = 'Alias Chatter Model'
|
||||
_name = 'mail.test'
|
||||
_mail_post_access = 'read'
|
||||
_inherit = ['mail.thread', 'mail.alias.mixin']
|
||||
|
||||
name = fields.Char()
|
||||
description = fields.Text()
|
||||
alias_id = fields.Many2one(
|
||||
'mail.alias', 'Alias',
|
||||
delegate=True)
|
||||
|
||||
def get_alias_model_name(self, vals):
|
||||
return vals.get('alias_model', 'mail.test')
|
||||
|
||||
def get_alias_values(self):
|
||||
self.ensure_one()
|
||||
res = super(MailTestAlias, self).get_alias_values()
|
||||
res['alias_force_thread_id'] = self.id
|
||||
res['alias_parent_thread_id'] = self.id
|
||||
return res
|
||||
@@ -1,3 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import data
|
||||
from . import models
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import test_mail_models
|
||||
from . import test_mail_models
|
||||
@@ -1,7 +1,100 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import models, fields, api
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class MailTestSimple(models.Model):
|
||||
""" A very simple model only inheriting from mail.thread when only
|
||||
communication history is necessary. """
|
||||
_description = 'Simple Chatter Model'
|
||||
_name = 'mail.test.simple'
|
||||
_inherit = ['mail.thread']
|
||||
|
||||
name = fields.Char()
|
||||
email_from = fields.Char()
|
||||
|
||||
|
||||
class MailTestStandard(models.Model):
|
||||
""" This model can be used in tests when automatic subscription and simple
|
||||
tracking is necessary. Most features are present in a simple way. """
|
||||
_description = 'Standard Chatter Model'
|
||||
_name = 'mail.test.track'
|
||||
_inherit = ['mail.thread']
|
||||
|
||||
name = fields.Char()
|
||||
email_from = fields.Char()
|
||||
user_id = fields.Many2one('res.users', 'Responsible', track_visibility='onchange')
|
||||
umbrella_id = fields.Many2one('mail.test', track_visibility='onchange')
|
||||
|
||||
|
||||
class MailTestActivity(models.Model):
|
||||
""" This model can be used to test activities in addition to simple chatter
|
||||
features. """
|
||||
_description = 'Activity Model'
|
||||
_name = 'mail.test.activity'
|
||||
_inherit = ['mail.thread', 'mail.activity.mixin']
|
||||
|
||||
name = fields.Char()
|
||||
email_from = fields.Char()
|
||||
|
||||
|
||||
class MailTestFull(models.Model):
|
||||
""" This model can be used in tests when complex chatter features are
|
||||
required like modeling tasks or tickets. """
|
||||
_description = 'Full Chatter Model'
|
||||
_name = 'mail.test.full'
|
||||
_inherit = ['mail.thread']
|
||||
|
||||
name = fields.Char()
|
||||
email_from = fields.Char(track_visibility='always')
|
||||
count = fields.Integer(default=1)
|
||||
datetime = fields.Datetime(default=fields.Datetime.now)
|
||||
mail_template = fields.Many2one('mail.template', 'Template')
|
||||
customer_id = fields.Many2one('res.partner', 'Customer', track_visibility='onchange')
|
||||
user_id = fields.Many2one('res.users', 'Responsible', track_visibility='onchange')
|
||||
umbrella_id = fields.Many2one('mail.test', track_visibility='onchange')
|
||||
|
||||
def _track_template(self, tracking):
|
||||
res = super(MailTestFull, self)._track_template(tracking)
|
||||
record = self[0]
|
||||
changes, tracking_value_ids = tracking[record.id]
|
||||
if 'customer_id' in changes and record.mail_template:
|
||||
res['customer_id'] = (record.mail_template, {'composition_mode': 'mass_mail'})
|
||||
elif 'datetime' in changes:
|
||||
res['datetime'] = ('mail.track_template', {'composition_mode': 'mass_mail'})
|
||||
return res
|
||||
|
||||
def _track_subtype(self, init_values):
|
||||
self.ensure_one()
|
||||
if 'umbrella_id' in init_values and self.umbrella_id:
|
||||
return 'mail.track_subtype_umbrella'
|
||||
return super(MailTestFull, self)._track_subtype(init_values)
|
||||
|
||||
|
||||
class MailTestAlias(models.Model):
|
||||
""" This model can be used in tests when umbrella records like projects
|
||||
or teams are required. """
|
||||
_description = 'Alias Chatter Model'
|
||||
_name = 'mail.test'
|
||||
_mail_post_access = 'read'
|
||||
_inherit = ['mail.thread', 'mail.alias.mixin']
|
||||
|
||||
name = fields.Char()
|
||||
description = fields.Text()
|
||||
alias_id = fields.Many2one(
|
||||
'mail.alias', 'Alias',
|
||||
delegate=True)
|
||||
|
||||
def get_alias_model_name(self, vals):
|
||||
return vals.get('alias_model', 'mail.test')
|
||||
|
||||
def get_alias_values(self):
|
||||
self.ensure_one()
|
||||
res = super(MailTestAlias, self).get_alias_values()
|
||||
res['alias_force_thread_id'] = self.id
|
||||
res['alias_parent_thread_id'] = self.id
|
||||
return res
|
||||
|
||||
|
||||
class MailModel(models.Model):
|
||||
|
||||
@@ -1,2 +1,12 @@
|
||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
access_test_performance_mail,access_test_performance_mail,model_test_performance_mail,,1,1,1,1
|
||||
access_mail_test_simple_portal,mail.test.simple.portal,model_mail_test_simple,base.group_portal,1,0,0,0
|
||||
access_mail_test_simple_user,mail.test.simple.user,model_mail_test_simple,base.group_user,1,1,1,1
|
||||
access_mail_test_track_portal,mail.test.track.portal,model_mail_test_track,base.group_portal,0,0,0,0
|
||||
access_mail_test_track_user,mail.test.track.user.employee,model_mail_test_track,base.group_user,1,1,1,1
|
||||
access_mail_test_activity_portal,mail.test.activity.portal,model_mail_test_activity,base.group_portal,1,0,0,0
|
||||
access_mail_test_activity_user,mail.test.activity.user,model_mail_test_activity,base.group_user,1,1,1,1
|
||||
access_mail_test_full_portal,mail.test.full.portal,model_mail_test_full,base.group_portal,0,0,0,0
|
||||
access_mail_test_full_user,mail.test.full.user,model_mail_test_full,base.group_user,1,1,1,1
|
||||
access_mail_test_portal,mail.test.portal,model_mail_test,base.group_portal,1,1,0,0
|
||||
access_mail_test_user,mail.test.user,model_mail_test,base.group_user,1,1,1,1
|
||||
|
||||
|
@@ -1,3 +1,16 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import test_performance
|
||||
from . import test_mail_activity
|
||||
from . import test_mail_followers
|
||||
from . import test_mail_message
|
||||
from . import test_mail_mail
|
||||
from . import test_mail_channel
|
||||
from . import test_mail_gateway
|
||||
from . import test_mail_template
|
||||
from . import test_message_compose
|
||||
from . import test_message_track
|
||||
from . import test_invite
|
||||
from . import test_ir_actions
|
||||
from . import test_update_notification
|
||||
from . import test_discuss
|
||||
from . import test_performance
|
||||
@@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo.addons.mail.tests.common import BaseFunctionalTest, TestRecipients, MockEmails
|
||||
from odoo.addons.test_mail.tests.common import BaseFunctionalTest, TestRecipients, MockEmails
|
||||
|
||||
|
||||
class TestChatterTweaks(BaseFunctionalTest, TestRecipients):
|
||||
@@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo.addons.mail.tests import common
|
||||
from odoo.addons.test_mail.tests import common
|
||||
from odoo.tools import mute_logger
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ from datetime import date
|
||||
from dateutil.relativedelta import relativedelta
|
||||
|
||||
from odoo import exceptions
|
||||
from odoo.addons.mail.tests.common import BaseFunctionalTest
|
||||
from odoo.addons.test_mail.tests.common import BaseFunctionalTest
|
||||
from odoo.tools import mute_logger
|
||||
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
from email.utils import formataddr
|
||||
|
||||
from odoo.addons.mail.tests import common
|
||||
from odoo.addons.test_mail.tests import common
|
||||
from odoo.exceptions import AccessError, except_orm
|
||||
from odoo.tools import mute_logger
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
|
||||
from psycopg2 import IntegrityError
|
||||
|
||||
from odoo.addons.mail.tests import common
|
||||
from odoo.addons.test_mail.tests import common
|
||||
from odoo.tools.misc import mute_logger
|
||||
|
||||
|
||||
+2
-2
@@ -5,8 +5,8 @@ import socket
|
||||
|
||||
from email.utils import formataddr
|
||||
|
||||
from odoo.addons.mail.tests.data.test_mail_data import MAIL_TEMPLATE, MAIL_TEMPLATE_PLAINTEXT, MAIL_MULTIPART_MIXED, MAIL_MULTIPART_MIXED_TWO, MAIL_MULTIPART_IMAGE
|
||||
from odoo.addons.mail.tests.common import BaseFunctionalTest, MockEmails
|
||||
from odoo.addons.test_mail.data.test_mail_data import MAIL_TEMPLATE, MAIL_TEMPLATE_PLAINTEXT, MAIL_MULTIPART_MIXED, MAIL_MULTIPART_MIXED_TWO, MAIL_MULTIPART_IMAGE
|
||||
from odoo.addons.test_mail.tests.common import BaseFunctionalTest, MockEmails
|
||||
from odoo.tools import mute_logger
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
import itertools
|
||||
|
||||
from odoo.addons.mail.tests import common as mail_common
|
||||
from odoo.addons.test_mail.tests import common as mail_common
|
||||
from odoo.tests import common
|
||||
from odoo.tools import mute_logger
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
import base64
|
||||
|
||||
from odoo.addons.mail.tests import common
|
||||
from odoo.addons.test_mail.tests import common
|
||||
from odoo.exceptions import AccessError, except_orm
|
||||
from odoo.tools import mute_logger
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
import base64
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from odoo.addons.mail.tests.common import BaseFunctionalTest, MockEmails, TestRecipients
|
||||
from odoo.addons.test_mail.tests.common import BaseFunctionalTest, MockEmails, TestRecipients
|
||||
from odoo.tools import mute_logger, DEFAULT_SERVER_DATETIME_FORMAT
|
||||
|
||||
|
||||
+3
-3
@@ -5,9 +5,9 @@ import base64
|
||||
|
||||
from unittest.mock import patch
|
||||
|
||||
from odoo.addons.mail.tests.common import BaseFunctionalTest, MockEmails, TestRecipients
|
||||
from odoo.addons.mail.tests.data.test_mail_data import MAIL_TEMPLATE_PLAINTEXT
|
||||
from odoo.addons.mail.tests.models.test_mail_models import MailTestSimple
|
||||
from odoo.addons.test_mail.tests.common import BaseFunctionalTest, MockEmails, TestRecipients
|
||||
from odoo.addons.test_mail.data.test_mail_data import MAIL_TEMPLATE_PLAINTEXT
|
||||
from odoo.addons.test_mail.models.test_mail_models import MailTestSimple
|
||||
from odoo.exceptions import AccessError
|
||||
from odoo.tools import mute_logger
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@
|
||||
|
||||
from email.utils import formataddr
|
||||
|
||||
from odoo.addons.mail.tests import common
|
||||
from odoo.addons.test_mail.tests import common
|
||||
|
||||
|
||||
class TestTracking(common.BaseFunctionalTest, common.MockEmails):
|
||||
@@ -105,7 +105,7 @@ class TestTracking(common.BaseFunctionalTest, common.MockEmails):
|
||||
def test_message_track_template(self):
|
||||
""" Update some tracked fields linked to some template -> message with onchange + always tracked values """
|
||||
mail_template = self.env['mail.template'].create({
|
||||
'model_id': self.env.ref('mail.model_mail_test_full').id,
|
||||
'model_id': self.env.ref('test_mail.model_mail_test_full').id,
|
||||
'body_html': '<p>Hello ${object.name}</p>',
|
||||
'subject': 'Test Template',
|
||||
'partner_to': '${object.customer_id.id | safe}',
|
||||
Reference in New Issue
Block a user