diff --git a/rero_ils/modules/items/api/circulation.py b/rero_ils/modules/items/api/circulation.py index c15c42e824..dd21abf824 100644 --- a/rero_ils/modules/items/api/circulation.py +++ b/rero_ils/modules/items/api/circulation.py @@ -1241,7 +1241,10 @@ def available(self): An item is 'available' if there are no related request/active_loan and if the related circulation category doesn't specify a negative availability. + All masked items are considered as unavailable. """ + if self.get('_masked', False): + return False if self.item_has_active_loan_or_request() > 0: return False if self.circulation_category.get('negative_availability'): diff --git a/tests/api/test_availability.py b/tests/api/test_availability.py index 98ecb5b116..3eb698c15e 100644 --- a/tests/api/test_availability.py +++ b/tests/api/test_availability.py @@ -287,6 +287,13 @@ def test_item_holding_document_availability( assert document_availability_status( client, document.pid, librarian_martigny.user) + # masked item isn't available + item['_masked'] = True + item = item.update(item, dbcommit=True, reindex=True) + assert not item.available + del item['_masked'] + item.update(item, dbcommit=True, reindex=True) + # test can not request item already checked out to patron res = client.get( url_for(