1
# -*- coding: utf-8 -*-
2
##############################################################################
4
# This file is part of mail_attach_existing_attachment,
7
# Copyright (c) 2015 ACSONE SA/NV (<http://acsone.eu>)
9
# mail_attach_existing_attachment is free software:
10
# you can redistribute it and/or modify it under the terms of the GNU
11
# Affero General Public License as published by the Free Software
12
# Foundation,either version 3 of the License, or (at your option) any
15
# mail_attach_existing_attachment is distributed
16
# in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
17
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
18
# PURPOSE. See the GNU Affero General Public License for more details.
20
# You should have received a copy of the GNU Affero General Public License
21
# along with mail_attach_existing_attachment.
22
# If not, see <http://www.gnu.org/licenses/>.
24
##############################################################################
26
from openerp.tests import common
29
class TestAttachExistingAttachment(common.TransactionCase):
32
super(TestAttachExistingAttachment, self).setUp()
33
self.partner_obj = self.env['res.partner']
34
self.partner_01 = self.env.ref('base.res_partner_1')
36
def test_send_email_attachment(self):
37
attach1 = self.env['ir.attachment'].create({
38
'name': 'Attach1', 'datas_fname': 'Attach1',
39
'datas': 'bWlncmF0aW9uIHRlc3Q=',
40
'res_model': 'res.partner', 'res_id': self.partner_01.id})
41
vals = {'model': 'res.partner',
42
'partner_ids': [(6, 0, [self.partner_01.id])],
43
'res_id': self.partner_01.id,
44
'object_attachment_ids': [(6, 0, [attach1.id])]
46
mail = self.env['mail.compose.message'].create(vals)
47
values = mail.get_mail_values([self.partner_01.id])
48
self.assertTrue(attach1.id in
49
values[self.partner_01.id]['attachment_ids'])