[FIX] mass_mailing: duplicate the "Send final on" field when copy
Before this commit: In the `mailings` when we enable the A/B testing and click on the "Create an Alternative" button, the "Send final on" field doesn't copy to the new mailing. Reason: The related field are copy `false` by default. After this Commit: Now it will copy the "Send final on" into a new mailing closes odoo/odoo#138195 Task: 3465887 X-original-commit: 3d6dd2402a65af40c77692250fd710d3355960e7 Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
This commit is contained in:
@@ -539,6 +539,8 @@ class MassMailing(models.Model):
|
||||
default = dict(default or {}, contact_list_ids=self.contact_list_ids.ids)
|
||||
if self.mail_server_id and not self.mail_server_id.active:
|
||||
default['mail_server_id'] = self._get_default_mail_server_id()
|
||||
if self.ab_testing_enabled:
|
||||
default['ab_testing_schedule_datetime'] = self.ab_testing_schedule_datetime
|
||||
return super(MassMailing, self).copy(default=default)
|
||||
|
||||
def _group_expand_states(self, states, domain, order):
|
||||
|
||||
@@ -6,6 +6,8 @@ from datetime import datetime, timedelta
|
||||
from odoo.addons.mass_mailing.tests.common import MassMailCommon
|
||||
from odoo.tests import users, tagged
|
||||
from odoo.tools import mute_logger
|
||||
from odoo.tests.common import Form
|
||||
from odoo import fields
|
||||
|
||||
|
||||
@tagged('post_install', '-at_install')
|
||||
@@ -192,3 +194,11 @@ class TestMailingABTesting(MassMailCommon):
|
||||
ab_testing.action_send_mail()
|
||||
self.assertEqual(ab_testing.state, 'done')
|
||||
self.assertEqual(len(self._mails), 1)
|
||||
|
||||
def test_mailing_ab_testing_duplicate_date(self):
|
||||
""" Test that "Send final on" date value should be copied in new mass_mailing """
|
||||
ab_testing_mail_1 = Form(self.ab_testing_mailing_1)
|
||||
ab_testing_mail_1.ab_testing_schedule_datetime = datetime.now() + timedelta(days=10)
|
||||
action = ab_testing_mail_1.save().action_duplicate()
|
||||
ab_testing_mailing_2 = self.env[action['res_model']].browse(action['res_id'])
|
||||
self.assertEqual(fields.Datetime.to_string(ab_testing_mailing_2.ab_testing_schedule_datetime), ab_testing_mail_1.ab_testing_schedule_datetime)
|
||||
|
||||
Reference in New Issue
Block a user