diff --git a/rero_ils/modules/ill_requests/serializers.py b/rero_ils/modules/ill_requests/serializers.py index e1a739d088..a949346ebf 100644 --- a/rero_ils/modules/ill_requests/serializers.py +++ b/rero_ils/modules/ill_requests/serializers.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # # RERO ILS -# Copyright (C) 2019-2022 RERO +# Copyright (C) 2019-2024 RERO # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by @@ -17,6 +17,7 @@ """ILL Request serialization.""" +from flask_babel import gettext as _ from invenio_records_rest.serializers.response import record_responsify from rero_ils.modules.libraries.api import LibrariesSearch @@ -32,9 +33,11 @@ def _postprocess_search_hit(self, hit: dict) -> None: """Post-process each hit of a search result.""" metadata = hit.get('metadata', {}) if pid := metadata.get('pickup_location', {}).get('pid'): - location = self.get_resource(LocationsSearch(), pid) - pickup_name = location.get('ill_pickup_name', location.get('name')) - metadata['pickup_location']['name'] = pickup_name + if location := self.get_resource(LocationsSearch(), pid): + pickup_name = location.get('ill_pickup_name', location.get('name')) + metadata['pickup_location']['name'] = pickup_name + else: + metadata['pickup_location']['name'] = _('[Deleted]') super()._postprocess_search_hit(hit) def _postprocess_search_aggregations(self, aggregations: dict) -> None: