From d658cb6f7ecb18845a78d4708ee63ad1126f220f Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 7 Sep 2018 13:43:15 -0300 Subject: [PATCH] Bug 15184: Do copy items for not a serial OR if items are created on ordering MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Séverine QUEUNE Signed-off-by: Katrin Fischer Signed-off-by: Nick Clemens --- Koha/Acquisition/Order.pm | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/Koha/Acquisition/Order.pm b/Koha/Acquisition/Order.pm index af76ddd48c..8abfbdd197 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::Subscriptions; @@ -185,6 +186,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 duplicate_to my $duplicated_order = $order->duplicate_to($basket, [$default_values]); @@ -231,13 +246,16 @@ 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 ); + + if ( not $self->biblio->serial || $self->basket->effective_create_items eq 'ordering') { # Do copy items if not a serial OR if items are created on ordering + 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 ); + } } } ); -- 2.39.5