Skip to content

Commit

Permalink
loans: fix automatic item assignment on pending loans
Browse files Browse the repository at this point in the history
Fixes problem when the checked-in item will be assigned to all
pending loans of its document. Fixed by adding the parameter
assign_item to all the ITEM_RETURNED transitions.

This PR needs any  invenio-circulation v.a21

* Fixes inveniosoftware/invenio-circulation#127.
* Removes the temporary transitions file used as a work around earlier.

Co-Authored-by: Aly Badr <aly.badr@rero.ch>
  • Loading branch information
Aly Badr authored and blankoworld committed Jun 2, 2020
1 parent 0279c01 commit 9ca52ce
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 128 deletions.
26 changes: 17 additions & 9 deletions rero_ils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@
CIRCULATION_LOAN_MINTER, CIRCULATION_LOAN_PID_TYPE
from invenio_circulation.search.api import LoansSearch
from invenio_circulation.transitions.transitions import CreatedToPending, \
ItemAtDeskToItemOnLoan, ItemOnLoanToItemInTransitHouse, \
ItemOnLoanToItemOnLoan, PendingToItemAtDesk, \
PendingToItemInTransitPickup, ToItemOnLoan, ToCancelled
ItemAtDeskToItemOnLoan, ItemInTransitHouseToItemReturned, \
ItemOnLoanToItemInTransitHouse, ItemOnLoanToItemOnLoan, \
ItemOnLoanToItemReturned, PendingToItemAtDesk, \
PendingToItemInTransitPickup, ToCancelled, ToItemOnLoan
from invenio_records_rest.utils import allow_all, deny_all

from .modules.acq_accounts.api import AcqAccount
Expand All @@ -63,8 +64,6 @@
from .modules.loans.api import Loan
from .modules.loans.permissions import can_list_loan_factory, \
can_read_loan_factory
from .modules.loans.transitions import ItemInTransitHouseToItemReturned, \
ItemOnLoanToItemReturned
from .modules.loans.utils import can_be_requested, get_default_loan_duration, \
get_extension_params, is_item_available_for_checkout, \
loan_build_document_ref, loan_build_item_ref, loan_build_patron_ref, \
Expand Down Expand Up @@ -1665,6 +1664,7 @@ def _(x):
dest='ITEM_ON_LOAN',
trigger='checkout',
transition=ToItemOnLoan,
assign_item=False
),
],
'PENDING': [
Expand Down Expand Up @@ -1692,17 +1692,25 @@ def _(x):
dict(dest='CANCELLED', trigger='cancel', transition=ToCancelled)
],
'ITEM_ON_LOAN': [
dict(dest='ITEM_RETURNED',
transition=ItemOnLoanToItemReturned, trigger='checkin'),
dict(
dest='ITEM_RETURNED',
transition=ItemOnLoanToItemReturned,
trigger='checkin',
assign_item=False
),
dict(dest='ITEM_IN_TRANSIT_TO_HOUSE',
transition=ItemOnLoanToItemInTransitHouse, trigger='checkin'),
dict(dest='ITEM_ON_LOAN', transition=ItemOnLoanToItemOnLoan,
trigger='extend'),
dict(dest='CANCELLED', trigger='cancel', transition=ToCancelled)
],
'ITEM_IN_TRANSIT_TO_HOUSE': [
dict(dest='ITEM_RETURNED',
transition=ItemInTransitHouseToItemReturned, trigger='receive'),
dict(
dest='ITEM_RETURNED',
transition=ItemInTransitHouseToItemReturned,
trigger='receive',
assign_item=False
),
dict(dest='CANCELLED', trigger='cancel', transition=ToCancelled)
],
'ITEM_RETURNED': [],
Expand Down
119 changes: 0 additions & 119 deletions rero_ils/modules/loans/transitions.py

This file was deleted.

0 comments on commit 9ca52ce

Please sign in to comment.