@@ -, +, @@ retrieving item type Can't call method "itemtype" on an undefined value at C4/Circulation.pm line 1826. Note: Bugs 19070/19071 address three tests that call AddReturn too. has all the tests successful. --- C4/Circulation.pm | 8 ++++---- t/db_dependent/Circulation/Returns.t | 4 +++- 2 files changed, 7 insertions(+), 5 deletions(-) --- a/C4/Circulation.pm +++ a/C4/Circulation.pm @@ -41,6 +41,7 @@ use Algorithm::CheckDigits; use Data::Dumper; use Koha::Account; use Koha::AuthorisedValues; +use Koha::Biblioitems; use Koha::DateUtils; use Koha::Calendar; use Koha::Checkouts; @@ -1820,10 +1821,9 @@ sub AddReturn { } my $itemnumber = $item->{ itemnumber }; - - my $item_level_itypes = C4::Context->preference("item-level_itypes"); - my $biblio = $item_level_itypes ? undef : Koha::Biblios->find( $item->{ biblionumber } ); # don't get bib data unless we need it - my $itemtype = $item_level_itypes ? $item->{itype} : $biblio->biblioitem->itemtype; + my $itemtype = C4::Context->preference("item-level_itypes") + ? $item->{itype} + : Koha::Biblioitems->find( $item->{biblioitemnumber} )->itemtype; my $issue = Koha::Checkouts->find( { itemnumber => $itemnumber } ); if ( $issue ) { --- a/t/db_dependent/Circulation/Returns.t +++ a/t/db_dependent/Circulation/Returns.t @@ -202,7 +202,7 @@ subtest "AddReturn logging on statistics table (item-level_itypes=0)" => sub { t::lib::Mocks::mock_preference( "IssueLog", 1 ); t::lib::Mocks::mock_preference( "ReturnLog", 1 ); - # Set item-level item types + # Set biblio level item types t::lib::Mocks::mock_preference( "item-level_itypes", 0 ); # Create an itemtype for biblio-level item type @@ -234,6 +234,7 @@ subtest "AddReturn logging on statistics table (item-level_itypes=0)" => sub { source => 'Item', value => { biblionumber => $biblionumber, + biblioitemnumber => $biblioitemnumber, homebranch => $branch, holdingbranch => $branch, itype => $ilevel_itemtype @@ -243,6 +244,7 @@ subtest "AddReturn logging on statistics table (item-level_itypes=0)" => sub { source => 'Item', value => { biblionumber => $biblionumber, + biblioitemnumber => $biblioitemnumber, homebranch => $branch, holdingbranch => $branch, itype => undef --