Bug 31105

Summary: Holds to pull counts items from other branches when independentbranches is active
Product: Koha Reporter: Shi Yao Wang <shi-yao.wang>
Component: Hold requestsAssignee: Shi Yao Wang <shi-yao.wang>
Status: CLOSED FIXED QA Contact: Kyle M Hall (khall) <kyle>
Severity: enhancement    
Priority: P5 - low CC: fridolin.somers, gmcharlt, kyle, lucas, philippe.blouin, sally.healey, shi-yao.wang
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35139
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
22.11.00
Circulation function:
Attachments: Bug 31105: Holds to pull counts items from other branches when independentbranches is active
Bug 31105: Holds to pull counts items from other branches when independentbranches is active
Bug 31105: Holds to pull counts items from other branches when independentbranches is active
Bug 31105: Regression tests

Description Shi Yao Wang 2022-07-05 15:24:33 UTC
Holds to pull should not take into account items from other branches that shares a record.

To recreate:
1- Have IndependentBranches set to Yes
2- Have a record with 2 items from different branches (set both current/home library)
3- Have a patron from one of the 2 branches in the previous step place a record level hold on that record
4- Go to circulation > holds to pull
5- Notice under "Libraries" it displays 2 branches, the current branch where the patron is from and another one. Also, it shows 2 under "Items available"
6- Checkout the item from the current branch to another patron
7- Go back to circulation > holds to pull
8- Notice under "Libraries" it displays the other branch that is not the current one
Comment 1 Shi Yao Wang 2022-07-05 17:46:57 UTC
Created attachment 137181 [details] [review]
Bug 31105: Holds to pull counts items from other branches when independentbranches is active

Holds to pull should not show items from other branches that shares a
record when IndependentBranches is active. Except for superlibrarians.

Test plan:
1- Have IndependentBranches set to Yes
2- Have a record with an item from the current branch and another item from a different branch. We will call them branch A and branch B respectively
3- Have a patron from branch A place a hold on that record
4- Have a staff account on branch A and B with the following permissions:
    - circulate (all)
    - catalogue
5- Go to circulation > holds to pull
6- Notice under "Libraries" it displays branch A and B. Also, it shows 2 under "Items available"
7- Checkout the item from branch A to another patron
8- Go back to circulation > holds to pull
9- Notice under "Libraries" it displays branch B even though we are in branch A
10- Apply the patch
11- Return the checked out item from step 7
12- Redo step 5 to 9 with superlibrarian privileges and notice nothing changed
13- Redo step 11-12 but using accounts from step 4 and notice Holds to
pull only shows information relevant to their branch
Comment 2 Biblibre Sandboxes 2022-07-19 09:45:47 UTC
Created attachment 137859 [details] [review]
Bug 31105: Holds to pull counts items from other branches when independentbranches is active

Holds to pull should not show items from other branches that shares a
record when IndependentBranches is active. Except for superlibrarians.

Test plan:
1- Have IndependentBranches set to Yes
2- Have a record with an item from the current branch and another item from a different branch. We will call them branch A and branch B respectively
3- Have a patron from branch A place a hold on that record
4- Have a staff account on branch A and B with the following permissions:
    - circulate (all)
    - catalogue
5- Go to circulation > holds to pull
6- Notice under "Libraries" it displays branch A and B. Also, it shows 2 under "Items available"
7- Checkout the item from branch A to another patron
8- Go back to circulation > holds to pull
9- Notice under "Libraries" it displays branch B even though we are in branch A
10- Apply the patch
11- Return the checked out item from step 7
12- Redo step 5 to 9 with superlibrarian privileges and notice nothing changed
13- Redo step 11-12 but using accounts from step 4 and notice Holds to
pull only shows information relevant to their branch

Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk>
Comment 3 Sally 2022-07-19 09:46:08 UTC
Works as described, thanks for the patch!
Comment 4 Kyle M Hall (khall) 2022-08-19 13:58:05 UTC
Created attachment 139496 [details] [review]
Bug 31105: Holds to pull counts items from other branches when independentbranches is active

Holds to pull should not show items from other branches that shares a
record when IndependentBranches is active. Except for superlibrarians.

Test plan:
1- Have IndependentBranches set to Yes
2- Have a record with an item from the current branch and another item from a different branch. We will call them branch A and branch B respectively
3- Have a patron from branch A place a hold on that record
4- Have a staff account on branch A and B with the following permissions:
    - circulate (all)
    - catalogue
5- Go to circulation > holds to pull
6- Notice under "Libraries" it displays branch A and B. Also, it shows 2 under "Items available"
7- Checkout the item from branch A to another patron
8- Go back to circulation > holds to pull
9- Notice under "Libraries" it displays branch B even though we are in branch A
10- Apply the patch
11- Return the checked out item from step 7
12- Redo step 5 to 9 with superlibrarian privileges and notice nothing changed
13- Redo step 11-12 but using accounts from step 4 and notice Holds to
pull only shows information relevant to their branch

Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 5 Tomás Cohen Arazi (tcohen) 2022-09-23 12:57:32 UTC
Created attachment 140902 [details] [review]
Bug 31105: Regression tests

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 6 Tomás Cohen Arazi (tcohen) 2022-09-23 12:59:05 UTC
Pushed to master for 22.11.

Nice work everyone, thanks!
Comment 7 Fridolin Somers 2023-10-23 20:29:29 UTC
-if ( C4::Context->preference('IndependentBranches') ){
+if ( C4::Context->only_my_library() ){


This change seems not related to this problem.
It changes behavior for superlibrarians with IndependentBranches = Yes.

So now behavior is different from waitingreserves.pl

I create a new bug report if we agree.