From b939a1bfd8a41989e3ed65cec3bf2f368dc17c09 Mon Sep 17 00:00:00 2001 From: Colin Campbell Date: Wed, 29 Jul 2020 13:23:14 +0100 Subject: [PATCH] Bug 26082 - Call store on new items to update itemnumber Need to add call to store to Koha::Item->new so that itemnumber is returned - otherwise is not defined and causes an error Bug is a side-effect of Bug 23463 as this was implicitly done in AddItem Also set biblioitemnumber explicitly for item adds this also used to be done explicitly but can now cause an FK error --- Koha/EDI.pm | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Koha/EDI.pm b/Koha/EDI.pm index a692da146b..3b89d4e5f4 100644 --- a/Koha/EDI.pm +++ b/Koha/EDI.pm @@ -719,7 +719,8 @@ sub quote_item { my $created = 0; while ( $created < $order_quantity ) { $item_hash->{biblionumber} = $bib->{biblionumber}; - my $item = Koha::Item->new( $item_hash ); + $item_hash->{biblioitemnumber} = $bib->{biblioitemnumber}; + my $item = Koha::Item->new( $item_hash )->store; my $itemnumber = $item->itemnumber; $logger->trace("Added item:$itemnumber"); $schema->resultset('AqordersItem')->create( @@ -810,7 +811,8 @@ sub quote_item { } $item_hash->{biblionumber} = $bib->{biblionumber}; - my $item = Koha::Item->new( $item_hash ); + $item_hash->{biblioitemnumber} = $bib->{biblioitemnumber}; + my $item = Koha::Item->new( $item_hash )->store; my $itemnumber = $item->itemnumber; $logger->trace("New item $itemnumber added"); $schema->resultset('AqordersItem')->create( @@ -879,7 +881,8 @@ sub quote_item { homebranch => $item->girfield( 'branch', $occurrence ), }; $new_item->{biblionumber} = $bib->{biblionumber}; - my $item = Koha::Item->new( $new_item ); + $new_item->{biblioitemnumber} = $bib->{biblioitemnumber}; + my $item = Koha::Item->new( $new_item )->store; my $itemnumber = $item->itemnumber; $logger->trace("New item $itemnumber added"); $schema->resultset('AqordersItem')->create( -- 2.26.2