Skip to content

Commit

Permalink
holdings: fix serial item deletion in ES
Browse files Browse the repository at this point in the history
* Fixes deletion of items in ES for serial holdings.

Co-Authored-by: Peter Weber <[email protected]>
  • Loading branch information
rerowep and rerowep committed Oct 13, 2021
1 parent 6916a6e commit 5046dad
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions rero_ils/modules/holdings/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,7 @@ def delete(self, force=False, dbcommit=False, delindex=False):
# Delete all attached items
for item in self.get_items:
item.delete(
force=force, dbcommit=dbcommit, delindex=delindex)
if delindex:
ItemsSearch.flush_and_refresh()
force=force, dbcommit=dbcommit, delindex=False)
return super().delete(
force=force, dbcommit=dbcommit, delindex=delindex)
else:
Expand Down Expand Up @@ -759,6 +757,11 @@ def delete(self, record):
:param record: Record instance.
"""
# Delete all attached items
if record.is_serial:
query = ItemsSearch().filter('term', holding__pid=record.pid)
query.delete()
ItemsSearch.flush_and_refresh()
document = Document.get_record_by_pid(record.document_pid)
return_value = super().delete(record)
document.reindex()
Expand Down

0 comments on commit 5046dad

Please sign in to comment.