Bugzilla – Attachment 95937 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), 3.91 KB, created by
Jonathan Druart
on 2019-12-03 10:11:43 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-03 10:11:43 UTC
Size:
3.91 KB
patch
obsolete
>From 9668a3c9b15a72ddffa0a00fdb4b054dbfdbe6d3 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 >Place a biblio-level hold on B1 and B2 >Place an item-level hold on B3 >Confirm the holds (to mark them waiting) > >1/ Use the 5 items and delete them in a batch. >=> delete of item from B1 is blocked on first screen >=> delete of items from B2 is *not* blocked on first screen >=> delete of item from B3 is blocked on first screen >=> delete of item from B4 is *not* blocked > >Note that you can only select items from B2 and B4 > >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! >--- > Koha/Item.pm | 11 +++++++++++ > t/db_dependent/Items_DelItemCheck.t | 21 +++++++++++---------- > 2 files changed, 22 insertions(+), 10 deletions(-) > >diff --git a/Koha/Item.pm b/Koha/Item.pm >index 6898520b59..c67ebe7866 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,15 @@ 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( >+ { >+ found => [ 'W', 'T' ], >+ itemnumber => undef, >+ } >+ ); >+ > 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