Skip to content

Commit

Permalink
item types: deny deletion with temporary item type
Browse files Browse the repository at this point in the history
* Denies the deletion of item type when it"s used by any item.
* Closes rero#2159.

Co-Authored-by: Bertrand Zuchuat <[email protected]>
  • Loading branch information
Garfield-fr committed Jul 14, 2021
1 parent ea59b72 commit 8776104
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions rero_ils/modules/item_types/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,10 @@ def exist_name_and_organisation_pid(cls, name, organisation_pid):
def get_number_of_items(self):
"""Get number of items."""
from ..items.api import ItemsSearch
return ItemsSearch() \
.filter('term', item_type__pid=self.pid) \
.source().count()
return ItemsSearch().query(
Q("match", item_type__pid=self.pid) |
Q("match", temporary_item_type__pid=self.pid)
).count()

def get_number_of_circ_policies(self):
"""Get number of circulation policies."""
Expand Down

0 comments on commit 8776104

Please sign in to comment.