You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
2.0 KiB

  1. # -*- coding: utf-8 -*-
  2. ##############################################################################
  3. #
  4. # This file is part of mail_attach_attachment,
  5. # an Odoo module.
  6. #
  7. # Copyright (c) 2015 ACSONE SA/NV (<http://acsone.eu>)
  8. #
  9. # mail_attach_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
  13. # later version.
  14. #
  15. # mail_attach_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.
  19. #
  20. # You should have received a copy of the GNU Affero General Public License
  21. # along with mail_attach_attachment.
  22. # If not, see <http://www.gnu.org/licenses/>.
  23. #
  24. ##############################################################################
  25. from openerp.tests import common
  26. class TestAttachAttachment(common.TransactionCase):
  27. def setUp(self):
  28. super(TestAttachAttachment, self).setUp()
  29. self.partner_obj = self.env['res.partner']
  30. self.partner_01 = self.env.ref('base.res_partner_1')
  31. def test_send_email_attachment(self):
  32. attach1 = self.env['ir.attachment'].create({
  33. 'name': 'Attach1', 'datas_fname': 'Attach1',
  34. 'datas': 'bWlncmF0aW9uIHRlc3Q=',
  35. 'res_model': 'res.partner', 'res_id': self.partner_01.id})
  36. vals = {'model': 'res.partner',
  37. 'partner_ids': [(6, 0, [self.partner_01.id])],
  38. 'res_id': self.partner_01.id,
  39. 'object_attachment_ids': [(6, 0, [attach1.id])]
  40. }
  41. mail = self.env['mail.compose.message'].create(vals)
  42. values = mail.get_mail_values(mail, [self.partner_01.id])
  43. self.assertTrue(attach1.id in
  44. values[self.partner_01.id]['attachment_ids'])