diff --git a/C4/Items.pm b/C4/Items.pm index 339aac869a..4fe6c64639 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -308,7 +308,8 @@ sub ModItemFromMarc { my $item_object = Koha::Items->find($itemnumber); my $item = TransformMarcToKoha( $localitemmarc, $frameworkcode, 'items' ); - my $has_permanent_location = exists $item->{permanent_location}; + my ( $perm_loc_tag, $perm_loc_subfield ) = C4::Biblio::GetMarcFromKohaField( "items.permanent_location" ); + my $has_permanent_location = defined $item_marc->subfield( $perm_loc_tag, $perm_loc_subfield ); # Retrieving the values for the fields that are not linked my @mapped_fields = Koha::MarcSubfieldStructures->search( diff --git a/t/db_dependent/Items.t b/t/db_dependent/Items.t index 0a018f1923..52d9068147 100755 --- a/t/db_dependent/Items.t +++ b/t/db_dependent/Items.t @@ -1120,11 +1120,11 @@ subtest 'ModItemFromMarc' => sub { $item->permanent_location(""); $item->location('E'); $marc = C4::Items::Item2Marc( $item->unblessed, $item->biblionumber ); + $marc->field('952')->add_subfields( "C", "" ); ModItemFromMarc( $marc, $item->biblionumber, $item->itemnumber ); $item = $item->get_from_storage; is( $item->location, 'E', 'next new location set as expected' ); is( $item->permanent_location, undef, 'permanent location is not updated if previously set as blank string' ); - }; $schema->storage->txn_rollback;