Bugzilla – Attachment 165002 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.65 KB, created by
Martin Renvoize
on 2024-04-17 12:33:37 UTC
(
hide
)
Description:
Bug 27893: Cancel acq orders in addbiblio.pl
Filename:
MIME Type:
Creator:
Martin Renvoize
Created:
2024-04-17 12:33:37 UTC
Size:
2.65 KB
patch
obsolete
>From e49bd3e51d386267b40d5835a05efe81986a6dd0 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 > >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> >Signed-off-by: David Nind <david@davidnind.com> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > cataloguing/addbiblio.pl | 26 +++++++++++++++++++++----- > 1 file changed, 21 insertions(+), 5 deletions(-) > >diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl >index 6230c922f6e..9d5a2165495 100755 >--- a/cataloguing/addbiblio.pl >+++ b/cataloguing/addbiblio.pl >@@ -20,9 +20,10 @@ > # along with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >- > use CGI; > use POSIX; >+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( >@@ -48,6 +49,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; >@@ -779,15 +781,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.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