Bugzilla – Attachment 165003 Details for
Bug 27893
Deleting a bibliographic record should warn about attached acquisition orders and cancel them
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27893: Optionally skip biblio with open orders in batch delete
Bug-27893-Optionally-skip-biblio-with-open-orders-.patch (text/plain), 5.16 KB, created by
Martin Renvoize (ashimema)
on 2024-04-17 12:33:39 UTC
(
hide
)
Description:
Bug 27893: Optionally skip biblio with open orders in batch delete
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2024-04-17 12:33:39 UTC
Size:
5.16 KB
patch
obsolete
>From 26c87146d4c5d86f5bcbe52b6b95c5f6fb4eddf6 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Mon, 19 Feb 2024 13:24:47 +0000 >Subject: [PATCH] Bug 27893: Optionally skip biblio with open orders in batch > delete > >If the user unchecks the skip checkbox (on by default), we must >make sure that order cancellation is done in background job. > >Test plan: >Pick two biblios. One has linked open orders, the other not. >Go to batch delete records. Select 'Enter list of numbers'. >Enter both biblio numbers and check that only one is used on the >follow-up form. >Run the deletion without the skip open orders and verify >that linked order line is cancelled. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Signed-off-by: David Nind <david@davidnind.com> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > Koha/BackgroundJob/BatchDeleteBiblio.pm | 8 ++++++++ > .../prog/en/modules/tools/batch_delete_records.tt | 6 ++++++ > tools/batch_delete_records.pl | 15 ++++++++++++--- > 3 files changed, 26 insertions(+), 3 deletions(-) > >diff --git a/Koha/BackgroundJob/BatchDeleteBiblio.pm b/Koha/BackgroundJob/BatchDeleteBiblio.pm >index 0709fd259a4..2054a726fe0 100644 >--- a/Koha/BackgroundJob/BatchDeleteBiblio.pm >+++ b/Koha/BackgroundJob/BatchDeleteBiblio.pm >@@ -7,6 +7,7 @@ use C4::Biblio; > use Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue; > use Koha::SearchEngine; > use Koha::SearchEngine::Indexer; >+use Koha::Acquisition::Orders; > > use base 'Koha::BackgroundJob'; > >@@ -123,6 +124,13 @@ sub process { > } > } > >+ # Cancel acq order lines >+ my @result = Koha::Acquisition::Orders->search( { biblionumber => $biblionumber } )->cancel; >+ my $warns = @{ $result[1] }; >+ if ( $result[0] && $warns ) { # warnings about order lines not removed >+ warn sprintf( "%d order lines were deleted, but %d lines gave a warning\n", $result[0], $warns ); >+ } >+ > # Finally, delete the biblio > my $error = eval { > C4::Biblio::DelBiblio( $biblionumber, { skip_record_index => 1, skip_holds_queue => 1 } ); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_delete_records.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_delete_records.tt >index d9930db1dae..4c7ca5a5f3f 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_delete_records.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_delete_records.tt >@@ -89,6 +89,10 @@ > <ol> > <li><label for="biblio_type">Bibliographic: </label><input type="radio" name="recordtype" value="biblio" id="biblio_type" checked="checked" /></li> > <li><label for="authority_type">Authorities: </label><input type="radio" name="recordtype" value="authority" id="authority_type" /></li> >+ <li class="skip_open_orders"> >+ <input type="checkbox" name="skip_open_orders" checked /> >+ <label for="skip_open_orders">Skip biblio records with open acquisition orders</label> >+ </li> > </ol> > </fieldset> > >@@ -260,8 +264,10 @@ > $("input[type='radio']").click(function() { > if ($(this).attr('id') == 'authority_type') { > $("a[href='#shelves_tab_panel']").parent().hide(); >+ $("li.skip_open_orders").hide(); > } else if ($(this).attr('id') == 'biblio_type') { > $("a[href='#shelves_tab_panel']").parent().show(); >+ $("li.skip_open_orders").show(); > } > }); > >diff --git a/tools/batch_delete_records.pl b/tools/batch_delete_records.pl >index 9164235bc8a..ea4a5a9ba45 100755 >--- a/tools/batch_delete_records.pl >+++ b/tools/batch_delete_records.pl >@@ -29,6 +29,7 @@ use C4::Output qw( output_html_with_http_headers ); > use C4::Auth qw( get_template_and_user ); > use C4::Biblio; > use C4::AuthoritiesMarc; >+use Koha::Acquisition::Orders; > use Koha::Virtualshelves; > > use Koha::Authorities; >@@ -37,9 +38,10 @@ use Koha::Items; > use Koha::BackgroundJob::BatchDeleteBiblio; > use Koha::BackgroundJob::BatchDeleteAuthority; > >-my $input = CGI->new; >-my $op = $input->param('op') // q|form|; >-my $recordtype = $input->param('recordtype') // 'biblio'; >+my $input = CGI->new; >+my $op = $input->param('op') // q|form|; >+my $recordtype = $input->param('recordtype') // 'biblio'; >+my $skip_open_orders = $input->param('skip_open_orders') // 0; > > my ($template, $loggedinuser, $cookie) = get_template_and_user({ > template_name => 'tools/batch_delete_records.tt', >@@ -106,6 +108,13 @@ if ( $op eq 'form' ) { > $biblio->{holds_count} = $biblio_object->holds->count; > $biblio->{issues_count} = C4::Biblio::CountItemsIssued( $record_id ); > $biblio->{subscriptions_count} = $biblio_object->subscriptions->count; >+ >+ # Respect skip_open_orders >+ next >+ if $skip_open_orders >+ && Koha::Acquisition::Orders->search( >+ { biblionumber => $record_id, orderstatus => [ 'new', 'ordered', 'partial' ] } )->count; >+ > push @records, $biblio; > } else { > # Retrieve authority information >-- >2.44.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 27893
:
118025
|
162271
|
162272
|
163669
|
163670
|
163676
|
163677
|
165002
| 165003 |
165151
|
165152
|
165620
|
165621