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.

35 lines
1.7 KiB

  1. # Copyright 2015 Guewen Baconnier (Camptocamp SA)
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  3. import odoo.tests.common as common
  4. class TestActiveSearch(common.TransactionCase):
  5. def test_model_with_active_field(self):
  6. IrModel = self.env['ir.model']
  7. partner_model = IrModel.search([('model', '=', 'res.partner')],
  8. limit=1)
  9. self.assertTrue(partner_model.has_an_active_field)
  10. self.assertIn(partner_model,
  11. IrModel.search([('has_an_active_field', '=', True)]))
  12. self.assertIn(partner_model,
  13. IrModel.search([('has_an_active_field', '!=', False)]))
  14. self.assertNotIn(partner_model,
  15. IrModel.search([('has_an_active_field', '!=', True)]))
  16. self.assertNotIn(partner_model,
  17. IrModel.search([('has_an_active_field', '=', False)]))
  18. def test_model_without_active_field(self):
  19. IrModel = self.env['ir.model']
  20. country_model = IrModel.search([('model', '=', 'res.country')],
  21. limit=1)
  22. self.assertFalse(country_model.has_an_active_field)
  23. self.assertIn(country_model,
  24. IrModel.search([('has_an_active_field', '!=', True)]))
  25. self.assertIn(country_model,
  26. IrModel.search([('has_an_active_field', '=', False)]))
  27. self.assertNotIn(country_model,
  28. IrModel.search([('has_an_active_field', '=', True)]))
  29. self.assertNotIn(country_model,
  30. IrModel.search([('has_an_active_field', '!=', False)])
  31. )