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.

25 lines
834 B

  1. from odoo.exceptions import UserError
  2. from odoo.tests import common
  3. class TestMobileCheckUnique(common.TransactionCase):
  4. def _create_partners(self, name, mobile, company_id=False):
  5. return self.env["res.partner"].create(
  6. {
  7. "name": name,
  8. "mobile": mobile,
  9. "company_id": company_id,
  10. }
  11. )
  12. def test_01_partner_mobile_unique(self):
  13. # create partners
  14. self.env.company.write({"partner_mobile_unique_filter_duplicates": True})
  15. with self.assertRaises(UserError):
  16. self._create_partners("Test Partner 1", "12345678")
  17. self._create_partners("Test Partner 2", "12345678")
  18. with self.assertRaises(UserError):
  19. self._create_partners("Test Partner 4", "12345678", self.env.company.id)