Bugzilla – Attachment 96148 Details for
Bug 8132
Batch delete tool deletes items with holds on them
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 8132: Adding a new message 'last_item_for_hold' blocking item deletion
Bug-8132-Adding-a-new-message-lastitemforhold-bloc.patch (text/plain), 4.45 KB, created by
Jonathan Druart
on 2019-12-10 12:32:46 UTC
(
hide
)
Description:
Bug 8132: Adding a new message 'last_item_for_hold' blocking item deletion
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2019-12-10 12:32:46 UTC
Size:
4.45 KB
patch
obsolete
>From af60db4886b7e99b68a373a48d2bfb319929041b Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 2 Dec 2019 16:32:13 +0100 >Subject: [PATCH] Bug 8132: Adding a new message 'last_item_for_hold' blocking > item deletion > >If an item is the last one of a biblio that have biblio-level hold >placed on it, we should block the deletion. >It takes effect if the hold is found (W or T), to follow existing >behavior for item-level holds. >If we want to block deletion for any holds we should deal with it on a >separate bug report. > >Test plan: >0/ Setup >Create Biblio B1 with 1 item >Create Biblio B2 with 2 items >Create Biblio B3 with 1+ item >Create Biblio B4 with 1+ item >Create Biblio B5 with 1+ item >Place a biblio-level hold on B1 and B2 >Place an item-level hold on B3 and B4 >Confirm the item-level hold for the items of B3 to mark it waiting. > >1/ Delete those 6 items in a batch >=> delete of item from B1 is blocked on first screen - only 1 item left >and there is a biblio-level hold on the record >=> delete of items from B2 is *not* blocked on first screen - One of >them will block the deletion, but so far we are not aware of that >situation >=> delete of item from B3 is blocked on first screen - there is a >waiting item-level hold placed on the item >=> delete of item from B4 is *not* blocked - there is a hold but it is >not found >=> delete of item from B5 is *not* - there is no reason to block its >deletion > >Note that you can only select items from B2, B4 and B5 > >2/ Select them and confirm the deletion >=> Nothing happened and you get a message saying that one of the 2 items >from B2 is blocking the whole deletion process > >3/ Remove the biblio-level hold >4/ Repeat 1 >=> The deletion has been effective! > >=> Note that there is something a bit weird as we are blocking items >from a biblio that has biblio-level holds on it (not found), but we >do not blocking the deletion of an item with a waiting item-level hold >--- > Koha/Item.pm | 10 ++++++++++ > t/db_dependent/Items_DelItemCheck.t | 21 +++++++++++---------- > 2 files changed, 21 insertions(+), 10 deletions(-) > >diff --git a/Koha/Item.pm b/Koha/Item.pm >index 6898520b59..028a32db8a 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -210,6 +210,8 @@ returns 1 if the item is safe to delete, > > "linked_analytics" if the item has linked analytic records. > >+"last_item_for_hold" if the item is the last one on a record on which a biblio-level hold is placed >+ > =cut > > sub safe_to_delete { >@@ -230,6 +232,14 @@ sub safe_to_delete { > return "linked_analytics" > if C4::Items::GetAnalyticsCount( $self->itemnumber ) > 0; > >+ return "last_item_for_hold" >+ if $self->biblio->items->count == 1 >+ && $self->biblio->holds->search( >+ { >+ itemnumber => undef, >+ } >+ )->count; >+ > return 1; > } > >diff --git a/t/db_dependent/Items_DelItemCheck.t b/t/db_dependent/Items_DelItemCheck.t >index b25be149da..951ab0e395 100644 >--- a/t/db_dependent/Items_DelItemCheck.t >+++ b/t/db_dependent/Items_DelItemCheck.t >@@ -24,7 +24,7 @@ use Koha::Items; > use t::lib::TestBuilder; > use t::lib::Mocks; > >-use Test::More tests => 9; >+use Test::More tests => 10; > use Test::MockModule; > > BEGIN { >@@ -71,20 +71,13 @@ my $patron = $builder->build( > } > ); > >-my $biblio = $builder->build( >- { >- source => 'Biblio', >- value => { >- branchcode => $branch->{branchcode}, >- }, >- } >-); >+my $biblio = $builder->build_sample_biblio({branchcode => $branch->{branchcode}}); > > my $item = $builder->build_object( > { > class => 'Koha::Items', > value => { >- biblionumber => $biblio->{biblionumber}, >+ biblionumber => $biblio->biblionumber, > homebranch => $branch->{branchcode}, > holdingbranch => $branch->{branchcode}, > withdrawn => 0, # randomly assigned value may block return. >@@ -153,6 +146,14 @@ $item->set( { homebranch => $branch->{branchcode}, holdingbranch => $branch->{br > > } > >+{ # last_item_for_hold >+ C4::Reserves::AddReserve($branch->{branchcode}, $patron->{borrowernumber}, $item->biblionumber ); >+ is( $item->safe_to_delete, 'last_item_for_hold', 'Item cannot be deleted if a biblio-level is placed on the biblio and there is only 1 item attached to the biblio' ); >+ >+ # With another item attached to the biblio, the item can be deleted >+ $builder->build_sample_item({ biblionumber => $item->biblionumber }); >+} >+ > is( > $item->safe_to_delete, > 1, >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 8132
:
95936
|
95937
|
95938
|
95939
|
95997
|
96147
|
96148
|
96149
|
96150
|
98694
|
98695
|
98696
|
98697
|
101404
|
101405
|
101406
|
101407
|
103147
|
103148
|
103149
|
103150
|
103166
|
103167
|
103168
|
103169
|
104567
|
104568
|
104569
|
104570
|
104571
|
104682