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.

53 lines
2.2 KiB

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