From e069690a92f5c5aaae96916011b25abc95ad65e7 Mon Sep 17 00:00:00 2001 From: Katrin Fischer Date: Sun, 12 Apr 2020 03:19:03 +0000 Subject: [PATCH] Bug 21927: Acq - Add blank values in pull downs of mandatory item subfields This is the same fix as on bug 14662, which fixed the behaviour in cataloguing, but for the item form in acquisitions. The code assumes that if a subfield is marked as mandatory, there should be no empty entry in the pull downs. This assumption is not correct, as it leads to the first entry of the pull down being preselected if there is no default set. As the field can never be 'unset', there will never be a 'required' warning. Furthermore, it might be counterproductive to use mandatory fields, as it might be easily forgotten to change the preselected value and those mistakes will be hard to find. Correct behaviour would be to preselect the empty value when there is no default. This means on saving the item an error message is triggered and the cataloger is forced to set the value. To test: - This is best tested with an ACQ framework, but default can be used when no ACQ framework was created. - In your MARC bibliographic framework: - In 952 make itemtype, classification source and some other pull downs like location or collection mandatory and set them to visibel if needed - Create a new basket with 'items created while ordering' - Add a new order, an existing record with 942$c set will work best - Add items for your order line - Verify that the first value of each pull down is preselected, there is no way to trigger the 'required' error - Apply patch - Add a new order line - Verify that classification source is preselected according to the DefaultClassificationSource system preference (try unsetting it later) - Verify all mandatory fields can be set to empty - Verify that you can't save before correctly setting them - Change your frameworks and set a default for itemtype (Ex: BK) and another mandatory and non-mandatory field of your choice - Add a new order line and item and verify the defaults are selected Signed-off-by: David Nind --- C4/Items.pm | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/C4/Items.pm b/C4/Items.pm index bbc5a7cd1f..f0fe9fc750 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -1680,8 +1680,7 @@ sub PrepareItemrecordDisplay { #----- itemtypes } elsif ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "itemtypes" ) { my $itemtypes = Koha::ItemTypes->search_with_localization; - push @authorised_values, "" - unless ( $tagslib->{$tag}->{$subfield}->{mandatory} ); + push @authorised_values, ""; while ( my $itemtype = $itemtypes->next ) { push @authorised_values, $itemtype->itemtype; $authorised_lib{$itemtype->itemtype} = $itemtype->translated_description; @@ -1692,7 +1691,7 @@ sub PrepareItemrecordDisplay { #---- class_sources } elsif ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "cn_source" ) { - push @authorised_values, "" unless ( $tagslib->{$tag}->{$subfield}->{mandatory} ); + push @authorised_values, ""; my $class_sources = GetClassSources(); my $default_source = $defaultvalue || C4::Context->preference("DefaultClassificationSource"); @@ -1712,8 +1711,7 @@ sub PrepareItemrecordDisplay { $tagslib->{$tag}->{$subfield}->{authorised_value}, $branch_limit ? $branch_limit : () ); - push @authorised_values, "" - unless ( $tagslib->{$tag}->{$subfield}->{mandatory} ); + push @authorised_values, ""; while ( my ( $value, $lib ) = $authorised_values_sth->fetchrow_array ) { push @authorised_values, $value; $authorised_lib{$value} = $lib; -- 2.11.0