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.

64 lines
2.2 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 = {
  12. 'name': '56048785',
  13. 'category_id': self.partner_id_category.id,
  14. }
  15. self.main_partner.write({'id_numbers': [(0, 0, vals)]})
  16. id_number = self.main_partner.id_numbers[0]
  17. self.assertEqual(id_number.name, '56048785')
  18. def test_02_id_number_duplicate(self):
  19. # Duplicate CoC
  20. vals = {
  21. 'name': '56048785',
  22. 'category_id': self.partner_id_category.id,
  23. }
  24. self.main_partner.write({'id_numbers': [(0, 0, vals)]})
  25. id_number_name = self.main_partner.id_numbers[0].name
  26. self.assertEqual(id_number_name, '56048785')
  27. new_partner = self.env['res.partner'].create({'name': 'Test Partner'})
  28. new_partner.write({'id_numbers': [(0, 0, vals)]})
  29. id_number_name = new_partner.id_numbers[0].name
  30. self.assertEqual(id_number_name, '56048785')
  31. def test_03_coc_registration_number_create(self):
  32. new_partner = self.env['res.partner'].create({
  33. 'name': 'Test Partner',
  34. 'coc_registration_number': '56048785',
  35. })
  36. self.assertEqual(new_partner.coc_registration_number, '56048785')
  37. id_numbers = new_partner.id_numbers
  38. self.assertTrue(id_numbers)
  39. self.assertEqual(len(id_numbers), 1)
  40. self.assertEqual(id_numbers.name, '56048785')
  41. def test_04_coc_registration_number_write(self):
  42. self.main_partner.write({
  43. 'coc_registration_number': '56048785'
  44. })
  45. coc = self.main_partner.coc_registration_number
  46. self.assertEqual(coc, '56048785')
  47. id_numbers = self.main_partner.id_numbers
  48. self.assertTrue(id_numbers)
  49. self.assertEqual(len(id_numbers), 1)
  50. self.assertEqual(id_numbers.name, '56048785')