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.

80 lines
2.9 KiB

  1. # Copyright 2018 Eficent Business and IT Consulting Services, S.L.
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  3. from odoo.tests.common import TransactionCase
  4. class TestMailActivityPartner(TransactionCase):
  5. def setUp(self):
  6. super(TestMailActivityPartner, self).setUp()
  7. self.user_admin = self.env.ref('base.user_root')
  8. self.employee = self.env['res.users'].create({
  9. 'company_id': self.env.ref("base.main_company").id,
  10. 'name': "Employee",
  11. 'login': "csu",
  12. 'email': "crmuser@yourcompany.com",
  13. 'groups_id': [(6, 0, [
  14. self.env.ref('base.group_user').id,
  15. self.env.ref('base.group_partner_manager').id])]
  16. })
  17. self.partner_ir_model = self.env['ir.model']._get('res.partner')
  18. activity_type_model = self.env['mail.activity.type']
  19. self.activity1 = activity_type_model.create({
  20. 'name': 'Initial Contact',
  21. 'days': 5,
  22. 'summary': 'ACT 1 : Presentation, barbecue, ... ',
  23. 'res_model_id': self.partner_ir_model.id,
  24. })
  25. self.activity2 = activity_type_model.create({
  26. 'name': 'Call for Demo',
  27. 'days': 6,
  28. 'summary': 'ACT 2 : I want to show you my ERP !',
  29. 'res_model_id': self.partner_ir_model.id,
  30. })
  31. self.partner_01 = self.env.ref('base.res_partner_1')
  32. self.homer = self.env['res.partner'].create({
  33. 'name': 'Homer Simpson',
  34. 'city': 'Springfield',
  35. 'street': '742 Evergreen Terrace',
  36. 'street2': 'Donut Lane',
  37. 'street3': 'Tho',
  38. })
  39. # test synchro of street3 on create
  40. self.partner_10 = self.env['res.partner'].create({
  41. 'name': 'Bart Simpson',
  42. 'parent_id': self.homer.id,
  43. 'type': 'contact',
  44. })
  45. def test_partner_for_activity(self):
  46. self.act1 = self.env['mail.activity'].sudo().create({
  47. 'activity_type_id': self.activity1.id,
  48. 'note': 'Partner activity 1.',
  49. 'res_id': self.partner_01.id,
  50. 'res_model_id': self.partner_ir_model.id,
  51. 'user_id': self.user_admin.id,
  52. })
  53. self.act2 = self.env['mail.activity'].sudo(self.employee).create({
  54. 'activity_type_id': self.activity2.id,
  55. 'note': 'Partner activity 10.',
  56. 'res_id': self.partner_10.id,
  57. 'res_model_id': self.partner_ir_model.id,
  58. 'user_id': self.employee.id,
  59. })
  60. # Check partner_id of created activities
  61. self.assertEqual(self.act1.partner_id, self.partner_01)
  62. self.assertEqual(self.act2.partner_id, self.partner_10)
  63. # Check commercial_partner_id for created activities
  64. self.assertEqual(self.act1.commercial_partner_id, self.partner_01)
  65. self.assertEqual(self.act2.commercial_partner_id, self.homer)