[IMP] base: return groups ordered in ACL error message

This allow error to have a predictable message. Forbid some tests to
fail randomly.
This commit is contained in:
Christophe Simonis
2019-06-11 16:37:14 +02:00
parent 10fac59172
commit 5983a05d57
+11 -7
View File
@@ -1202,13 +1202,17 @@ class IrModelAccess(models.Model):
:rtype: list
"""
assert access_mode in ('read', 'write', 'create', 'unlink'), 'Invalid access mode'
self._cr.execute("""SELECT c.name, g.name
FROM ir_model_access a
JOIN ir_model m ON (a.model_id=m.id)
JOIN res_groups g ON (a.group_id=g.id)
LEFT JOIN ir_module_category c ON (c.id=g.category_id)
WHERE m.model=%s AND a.active IS TRUE AND a.perm_""" + access_mode,
(model_name,))
self._cr.execute("""
SELECT c.name, g.name
FROM ir_model_access a
JOIN ir_model m ON (a.model_id = m.id)
JOIN res_groups g ON (a.group_id = g.id)
LEFT JOIN ir_module_category c ON (c.id = g.category_id)
WHERE m.model = %%s
AND a.active = TRUE
AND a.perm_%s = TRUE
ORDER BY c.name, g.name NULLS LAST
""" % access_mode, [model_name])
return [('%s/%s' % x) if x[0] else x[1] for x in self._cr.fetchall()]
# The context parameter is useful when the method translates error messages.