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.

36 lines
1.7 KiB

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