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

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
(cherry picked from commit b5a36c20a2)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Colin Campbell 2020-07-29 13:23:14 +01:00 committed by Lucas Gass
parent f470d3f75d
commit 8a4a166713
1 changed files with 6 additions and 3 deletions

View File

@ -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(