Bug 31460: Merge item groups when merging records
Test:
1. Have a record (A) with 3 items.
2. Create an item group with 2 of these items.
3. Have a second record (B) with 4 items
4. Create an item group with 2 of these items.
5. Merge the two records together keeping record A
6. Results will show that all items are moved over to record A, but the item group from record B, is not there.
7. Apply patch
8. Create a new record (C) with 3 items.
9. Create an item group with 2 of these items
10. Merge this into record A
11. The item groups are moved!
Signed-off-by: Miranda Nero <mnero@oslri.net>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit f7897d7d81)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
This commit is contained in:
parent
9e2eafec0e
commit
ba8d8ea3bc
|
|
@ -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 },
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue