cubicweb #17086023 Entity.complete() ignore ERQLExpressions [open]

complete() is supposed to fill the entity cache in a efficient way, but it ignore inlined relation with read permissions based on a ERQLExpression. Because _cw_to_complete_relations() only looks for group permissions.

Steps to reproduce:

from yams.buildobjs import EntityType, SubjectRelation
from cubicweb.schema import ERQLExpression


class Su(EntityType):
    r = SubjectRelation('Ob', cardinality='1*', inlined=True)

class Ob(EntityType):
    __permissions__ = {
        'read': ('managers', ERQLExpression('X owned_by U')),
        'add': ('managers', 'users'),
        'update': ('managers', 'owners'),
        'delete': ('managers', 'owners'),
    }

And this test fails:

from cubicweb.devtools.testlib import CubicWebTC


class TC(CubicWebTC):

    def test_complete(self):
        with self.admin_access.cnx() as cnx:
            self.create_user(cnx, 'alice')
            cnx.commit()
        with self.new_access('alice').cnx() as cnx:
            s = cnx.create_entity('Su')
            s.cw_set(r=cnx.create_entity('Ob'))
            cnx.commit()
        with self.admin_access.cnx() as cnx:
            s = cnx.find('Su').one()
            s.complete()
            assert list(s._cw_related_cache) == ['r_subject']
        with self.new_access('alice').cnx() as cnx:
            s = cnx.find('Su').one()
            s.complete()
            assert list(s._cw_related_cache) == ['r_subject']
E          AssertionError: assert [] == ['r_subject']
prioritynormal
typebug
done in<not specified>
closed by<not specified>