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.

44 lines
1.4 KiB

  1. # -*- coding: utf-8 -*-
  2. # Copyright 2017 LasLabs Inc.
  3. # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
  4. from lxml import etree
  5. from odoo.exceptions import AccessError
  6. from .common import Common
  7. class TestResCompany(Common):
  8. def test_fields_view_get(self):
  9. """
  10. It should verify that setting THRESHOLD_HIDE removes the parameter
  11. from the view
  12. """
  13. import odoo.addons.user_threshold.models.res_company as mdl
  14. mdl.THRESHOLD_HIDE = True
  15. view = self.env.ref('user_threshold.view_company_form')
  16. c = self.env['res.company'].browse(1)
  17. ret = c.fields_view_get(view.id)
  18. doc = etree.XML(ret['arch'])
  19. self.assertEquals(doc.xpath("//field[@name='max_users']"), [])
  20. def test_can_write_max_users(self):
  21. """
  22. It should restrict the max users parameter to Threshold Managers
  23. """
  24. u = self._create_test_user()
  25. self._add_user_to_group(u)
  26. c = self.env['res.company'].browse(1)
  27. res = 10
  28. c.sudo(u.id).write({'max_users': res})
  29. self.assertEquals(c.max_users, res)
  30. def test_cannot_write_max_users(self):
  31. """
  32. It should restrict the max users parameter to Threshold Managers
  33. """
  34. u = self._create_test_user()
  35. c = self.env['res.company'].browse(1)
  36. with self.assertRaises(AccessError):
  37. c.sudo(u.id).write({'max_users': 10})