Bugzilla – Attachment 163669 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: Cancel acq orders in addbiblio.pl
Bug-27893-Cancel-acq-orders-in-addbibliopl.patch (text/plain), 2.57 KB, created by
Marcel de Rooy
on 2024-03-22 10:02:27 UTC
(
hide
)
Description:
Bug 27893: Cancel acq orders in addbiblio.pl
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2024-03-22 10:02:27 UTC
Size:
2.57 KB
patch
obsolete
>From a2024fecd7566eaddcb77ea552f0635c06c1e968 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Mon, 19 Feb 2024 11:43:32 +0000 >Subject: [PATCH] Bug 27893: Cancel acq orders in addbiblio.pl >Content-Type: text/plain; charset=utf-8 > >When the user confirms removal although we have linked orders, >we should cancel them. > >Test plan: >Add order line to a basket. >Goto newly added biblio record, remove items, remove biblio. >Notice the warning about attached order lines. >Confirm. Check the basket again after deletion took place (cancelled line). > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > cataloguing/addbiblio.pl | 26 +++++++++++++++++++++----- > 1 file changed, 21 insertions(+), 5 deletions(-) > >diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl >index a340c6ebbf..407ef39585 100755 >--- a/cataloguing/addbiblio.pl >+++ b/cataloguing/addbiblio.pl >@@ -20,8 +20,9 @@ > # along with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >- > use CGI; >+use Try::Tiny qw(catch try); >+ > use C4::Output qw( output_html_with_http_headers ); > use C4::Auth qw( get_template_and_user haspermission ); > use C4::Biblio qw( >@@ -47,6 +48,7 @@ use C4::Charset qw( SetMarcUnicodeFlag ); > use Koha::BiblioFrameworks; > use Koha::DateUtils qw( dt_from_string ); > >+use Koha::Acquisition::Orders; > use Koha::Biblios; > use Koha::ItemTypes; > use Koha::Libraries; >@@ -765,15 +767,29 @@ if ( $op eq "cud-addbiblio" ) { > ); > } > } >-elsif ( $op eq "cud-delete" ) { > >- my $error = &DelBiblio($biblionumber); >+elsif ( $op eq "cud-delete" ) { >+ >+ # Cancel attached order lines first before deleting biblio ! >+ my $error; >+ try { >+ 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 ); >+ } >+ $error = &DelBiblio($biblionumber); >+ } catch { >+ $error = ref($_) ? 'Exception raised - ' . $_->error : $_; >+ }; >+ > if ($error) { >+ #FIXME This should be handled in template alert > warn "ERROR when DELETING BIBLIO $biblionumber : $error"; > print "Content-Type: text/html\n\n<html><body><h1>ERROR when DELETING BIBLIO $biblionumber : $error</h1></body></html>"; >- exit; >+ exit; > } >- >+ > print $input->redirect('/cgi-bin/koha/catalogue/search.pl' . ($searchid ? "?searchid=$searchid" : "")); > exit; > >-- >2.30.2
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