Bugzilla – Attachment 104568 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.92 KB, created by
Marcel de Rooy
on 2020-05-08 09:42:15 UTC
(
hide
)
Description:
Bug 8132: Adding a new message 'last_item_for_hold' blocking item deletion
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2020-05-08 09:42:15 UTC
Size:
3.92 KB
patch
obsolete
>From a57b87967cfccdcd507341c17b419235f153a5ea 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 >Content-Type: text/plain; charset=utf-8 > >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 >Apply the patches >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 from B2 >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 > >Signed-off-by: Kelly McElligott <kelly@bywatersolutions.com> >Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net> > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > Koha/Item.pm | 10 ++++++++++ > t/db_dependent/Koha/Item.t | 10 +++++++++- > 2 files changed, 19 insertions(+), 1 deletion(-) > >diff --git a/Koha/Item.pm b/Koha/Item.pm >index 9e1bca4ef5..57fe8f1b20 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -234,6 +234,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 { >@@ -254,6 +256,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/Koha/Item.t b/t/db_dependent/Koha/Item.t >index 55709643b7..517126130c 100644 >--- a/t/db_dependent/Koha/Item.t >+++ b/t/db_dependent/Koha/Item.t >@@ -342,7 +342,7 @@ subtest 'pickup_locations' => sub { > }; > > subtest 'deletion' => sub { >- plan tests => 11; >+ plan tests => 12; > > $schema->storage->txn_begin; > >@@ -430,6 +430,14 @@ subtest 'deletion' => sub { > > } > >+ { # last_item_for_hold >+ C4::Reserves::AddReserve($patron->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