From 4b06dc4d20a3b6c11c08571b35cce987817d2390 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 7 Sep 2018 13:43:15 -0300 Subject: [PATCH] Bug 15184: Do not copy items for serials --- Koha/Acquisition/Order.pm | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/Koha/Acquisition/Order.pm b/Koha/Acquisition/Order.pm index 9c0077fd9b..a314e6dcb5 100644 --- a/Koha/Acquisition/Order.pm +++ b/Koha/Acquisition/Order.pm @@ -24,6 +24,7 @@ use Koha::Acquisition::Funds; use Koha::Acquisition::Invoices; use Koha::Database; use Koha::DateUtils qw( dt_from_string output_pref ); +use Koha::Biblios; use Koha::Items; use Koha::Patrons; use Koha::Subscriptions; @@ -202,6 +203,20 @@ sub items { return Koha::Items->search({ itemnumber => \@itemnumbers }); } +=head3 biblio + + my $biblio = $order->biblio + +Returns the bibliographic record associated to the order + +=cut + +sub biblio { + my ( $self ) = @_; + my $biblio_rs= $self->_result->biblionumber; + return Koha::Biblio->_new_from_dbic( $biblio_rs ); +} + =head3 users my $patrons = $order->users @@ -263,13 +278,17 @@ sub duplicate_to { $order_info->{basketno} = $basket->basketno; $new_order = Koha::Acquisition::Order->new($order_info)->store; - my $items = $self->items; - while ( my ($item) = $items->next ) { - my $item_info = $item->unblessed; - undef $item_info->{itemnumber}; - undef $item_info->{barcode}; - my $new_item = Koha::Item->new($item_info)->store; - $new_order->add_item( $new_item->itemnumber ); + + unless ( $self->biblio->serial ) { # Do not copy items for serials + my $items = $self->items; + while ( my ($item) = $items->next ) { + my $item_info = $item->unblessed; + undef $item_info->{itemnumber}; + undef $item_info->{barcode}; + my $new_item = Koha::Item->new($item_info)->store; + warn "adding item $new_item->itemnumber to ..."; + $new_order->add_item( $new_item->itemnumber ); + } } my $users = $self->users; # Do we want ça? while ( my ($user) = $users->next ) { -- 2.11.0