diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm index 878f7cd15a..1ab18e828b 100644 --- a/Koha/Biblio.pm +++ b/Koha/Biblio.pm @@ -2343,6 +2343,12 @@ sub merge_with { my $from_biblio = Koha::Biblios->find($bn_merge); $from_biblio->items->move_to_biblio($self); + # Move item groups + $from_biblio->item_groups->update( + { biblio_id => $ref_biblionumber }, + { no_triggers => 1 } + ); + # Move article requests $from_biblio->article_requests->update( { biblionumber => $ref_biblionumber }, diff --git a/t/db_dependent/Koha/Biblio.t b/t/db_dependent/Koha/Biblio.t index 0d9d44a459..62ec87e40a 100755 --- a/t/db_dependent/Koha/Biblio.t +++ b/t/db_dependent/Koha/Biblio.t @@ -649,7 +649,7 @@ subtest 'bookings() tests' => sub { }; subtest 'merge of records' => sub { - plan tests => 8; + plan tests => 9; subtest 'move items' => sub { plan tests => 9; @@ -702,6 +702,26 @@ subtest 'merge of records' => sub { $schema->storage->txn_rollback; }; + subtest 'move item groups' => sub { + plan tests => 3; + $schema->storage->txn_begin; + + my $biblio1 = $builder->build_sample_biblio; + my $biblio2 = $builder->build_sample_biblio; + + my $ig1 = $builder->build_object( + { class => 'Koha::Biblio::ItemGroups', value => { biblio_id => $biblio1->biblionumber } } ); + my $ig2 = $builder->build_object( + { class => 'Koha::Biblio::ItemGroups', value => { biblio_id => $biblio2->biblionumber } } ); + + warning_like { $biblio1->merge_with( [ $biblio2->biblionumber ] ) } q{}; + + is( $ig1->get_from_storage->biblio_id, $biblio1->biblionumber ); + is( $ig2->get_from_storage->biblio_id, $biblio1->biblionumber ); + + $schema->storage->txn_rollback; + }; + subtest 'move article requests' => sub { plan tests => 3; $schema->storage->txn_begin;