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.

55 lines
2.1 KiB

  1. # Copyright 2018 Onestein (<http://www.onestein.eu>)
  2. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
  3. from odoo.tests.common import TransactionCase
  4. class TestPartnerCoC(TransactionCase):
  5. def setUp(self):
  6. super(TestPartnerCoC, self).setUp()
  7. self.main_partner = self.env.ref("base.main_partner")
  8. self.partner_id_category = self.env.ref("partner_coc.id_category_coc")
  9. def test_01_id_number_new(self):
  10. # Good CoC
  11. vals = {"name": "56048785", "category_id": self.partner_id_category.id}
  12. self.main_partner.write({"id_numbers": [(0, 0, vals)]})
  13. id_number = self.main_partner.id_numbers[0]
  14. self.assertEqual(id_number.name, "56048785")
  15. def test_02_id_number_duplicate(self):
  16. # Duplicate CoC
  17. vals = {"name": "56048785", "category_id": self.partner_id_category.id}
  18. self.main_partner.write({"id_numbers": [(0, 0, vals)]})
  19. id_number_name = self.main_partner.id_numbers[0].name
  20. self.assertEqual(id_number_name, "56048785")
  21. new_partner = self.env["res.partner"].create({"name": "Test Partner"})
  22. new_partner.write({"id_numbers": [(0, 0, vals)]})
  23. id_number_name = new_partner.id_numbers[0].name
  24. self.assertEqual(id_number_name, "56048785")
  25. def test_03_coc_registration_number_create(self):
  26. new_partner = self.env["res.partner"].create(
  27. {"name": "Test Partner", "coc_registration_number": "56048785"}
  28. )
  29. self.assertEqual(new_partner.coc_registration_number, "56048785")
  30. id_numbers = new_partner.id_numbers
  31. self.assertTrue(id_numbers)
  32. self.assertEqual(len(id_numbers), 1)
  33. self.assertEqual(id_numbers.name, "56048785")
  34. def test_04_coc_registration_number_write(self):
  35. self.main_partner.write({"coc_registration_number": "56048785"})
  36. coc = self.main_partner.coc_registration_number
  37. self.assertEqual(coc, "56048785")
  38. id_numbers = self.main_partner.id_numbers
  39. self.assertTrue(id_numbers)
  40. self.assertEqual(len(id_numbers), 1)
  41. self.assertEqual(id_numbers.name, "56048785")