diff options
| author | Christophe Simonis <chs@odoo.com> | 2019-05-29 11:10:34 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2019-05-29 11:10:34 +0200 |
| commit | 8a0e819d0bb0e4184ed64559b7be91605d044e19 (patch) | |
| tree | 777d65bf017d3946504268be8a7117c555c1aed9 /addons/test_mail/tests/test_mail_template.py | |
| parent | 5adbaf827e595199ea2df331fb207a5f0cd4928c (diff) | |
| parent | 3e12f2ff56eaa4950fd14d1a4bb29e3721c0268a (diff) | |
[MERGE] forward port branch 11.0 up to 3e12f2ff56e
Diffstat (limited to 'addons/test_mail/tests/test_mail_template.py')
| -rw-r--r-- | addons/test_mail/tests/test_mail_template.py | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/addons/test_mail/tests/test_mail_template.py b/addons/test_mail/tests/test_mail_template.py index 55ddbb7b667..bb4a96470d0 100644 --- a/addons/test_mail/tests/test_mail_template.py +++ b/addons/test_mail/tests/test_mail_template.py @@ -75,7 +75,7 @@ class TestMailTemplate(BaseFunctionalTest, MockEmails, TestRecipients): static attachments are not duplicated and while reports are re-generated, and that intermediary attachments are dropped.""" - composer = self.env['mail.compose.message'].create({}) + composer = self.env['mail.compose.message'].with_context(default_attachment_ids=[]).create({}) report_template = self.env.ref('web.action_report_externalpreview') template_1 = self.email_template.copy({ 'report_template': report_template.id, @@ -85,20 +85,20 @@ class TestMailTemplate(BaseFunctionalTest, MockEmails, TestRecipients): 'report_template': report_template.id, }) - onchange_templates = [template_1, template_2, template_1] - attachments_onchange = [] + onchange_templates = [template_1, template_2, template_1, False] + attachments_onchange = [composer.attachment_ids] # template_1 has two static attachments and one dynamically generated report, # template_2 only has the report, so we should get 3, 1, 3 attachments - attachment_numbers = [3, 1, 3] + attachment_numbers = [0, 3, 1, 3, 0] - for template in onchange_templates: - onchange = composer.onchange_template_id( - template.id, 'comment', 'mail.test', self.test_record.id - ) - values = composer._convert_to_record(composer._convert_to_cache(onchange['value'])) - attachments = values['attachment_ids'] - composer.attachment_ids = attachments # we apply the onchange - attachments_onchange.append(attachments) + with self.env.do_in_onchange(): + for template in onchange_templates: + onchange = composer.onchange_template_id( + template.id if template else False, 'comment', self.test_record._name, self.test_record.id + ) + values = composer._convert_to_record(composer._convert_to_cache(onchange['value'])) + attachments_onchange.append(values['attachment_ids']) + composer.update(onchange['value']) self.assertEqual( [len(attachments) for attachments in attachments_onchange], @@ -106,7 +106,7 @@ class TestMailTemplate(BaseFunctionalTest, MockEmails, TestRecipients): ) self.assertTrue( - len(attachments_onchange[0] & attachments_onchange[2]) == 2, + len(attachments_onchange[1] & attachments_onchange[3]) == 2, "The two static attachments on the template should be common to the two onchanges" ) |
