diff --git a/rero_ils/modules/patrons/api.py b/rero_ils/modules/patrons/api.py index 4fcf8b67eb..cf57c89610 100644 --- a/rero_ils/modules/patrons/api.py +++ b/rero_ils/modules/patrons/api.py @@ -426,8 +426,7 @@ def get_patrons_without_subscription(cls, patron_type_pid): """Get patrons linked to patron_type that haven't any subscription.""" query = PatronsSearch() \ .filter('term', patron__type__pid=patron_type_pid) \ - .filter('bool', must_not=[ - Q('exists', field="patron__subscriptions")]) + .exclude('exists', field='patron.subscriptions') for res in query.source('pid').scan(): yield Patron.get_record_by_pid(res.pid) diff --git a/tests/api/patrons/test_patrons_rest.py b/tests/api/patrons/test_patrons_rest.py index f0af1ddbb9..770575a97b 100644 --- a/tests/api/patrons/test_patrons_rest.py +++ b/tests/api/patrons/test_patrons_rest.py @@ -114,9 +114,9 @@ def test_patron_has_valid_subscriptions( patron_sion.add_subscription(patron_type_grown_sion, start, end) # !! As `add_subscription` use the method `Patron.update`, then the signal # `after_record_update` are send by invenio_records and the patron - # listener `reate_subscription_patron_transaction` is called. This + # listener `create_subscription_patron_transaction` is called. This # listener found that user doesn't have any subscription and add a valid - # one for this patron. So after `add_subscription` call, i just removed + # one for this patron. So after `add_subscription` call, I just removed # the valid subscription created. del patron_sion['patron']['subscriptions'][1] assert not patron_sion.has_valid_subscription