Bug 39282: Ensure items are created using Item Information values if not using MarcItemFieldsToOrder

When using MarcFieldsToOrder and not MarcItemFieldsToOrder it is expected that all of the item
information will come from the second tab 'Item information' on addorderiso2709.pl

Currently we are not and blank items are beign created

To test:
 1 - Apply unit tests
 2 - prove -v t/db_dependent/Koha/MarcOrder.t
 3 - It fails
 4 - Set MarcItemFields to Order:
     price: 949$p
     quantity: 947$c
     budget_code: 947$f
 5 - Ensure MarcItemFieldsToOrder is blank
 6 - Find a basket in acquisitions
 7 - Add to basket from a file
 8 - Fill item information, set 'Matching' at top of form to 'Do not look for matchign records' and save
 9 - Orders are added
10 - Click on a title
11 - Items do not load and an error is generated, this is because items don't have any values
12 - Check the DB:
     SELECT * FROM items WHERE homebranch IS NULL\G
13 - Note items from order are listed
14 - Apply the rest of the patches
15 - Repeat 6-10
16 - This time the items load successfully

NOTE: This patch alone doesn't address all errors, but subsequent will, keeping separate to address
each issue individually, but test plan can be executed as a whole against all

Signed-off-by: John Vinke <jvinke@austinseminary.edu>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit 5034c27628)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
This commit is contained in:
Nick Clemens 2025-03-12 16:25:37 +00:00 committed by Paul Derscheid
parent ed42030841
commit 67475d91db
No known key found for this signature in database
GPG Key ID: C25F9FD44CED595B
2 changed files with 4 additions and 1 deletions

View File

@ -958,7 +958,8 @@ sub create_items_and_generate_order_hash {
my $itemcreation = 0;
my @itemnumbers;
if ( C4::Context->preference('AcqCreateItem') ne 'cataloguing' ) {
# We directly create the items if MarcItemFieldsToOrder is populated (item fields have values)
if ( C4::Context->preference('AcqCreateItem') ne 'cataloguing' && @{ $fields->{homebranch} } ) {
for ( my $i = 0 ; $i < $loop_limit ; $i++ ) {
$itemcreation = 1;
my $item = Koha::Item->new(
@ -1052,6 +1053,7 @@ sub create_items_and_generate_order_hash {
}
} else {
# Here we are using the 'MARC' for items from the 'Item information' tab for creating the items
# Add an orderline for each MARC record
# Get quantity in the MARC record (1 if none)
my $quantity = GetMarcQuantity( $fields->{marcrecord}, C4::Context->preference('marcflavour') ) || 1;

View File

@ -443,6 +443,7 @@ subtest 'add_items_from_import_record() - addorderiso2709.pl' => sub {
subtest "Using MarcFieldsToOrder only" => sub {
plan tests => 9;
t::lib::Mocks::mock_userenv( { branchcode => $branchcode } );
my $client_item_fields = {
'tags' => [