From 4344c59731a2078a06239e588fc0cd022fadbc0a Mon Sep 17 00:00:00 2001 From: Andrew Nugged Date: Tue, 12 Nov 2019 19:50:58 +0000 Subject: [PATCH] Bug 23992: Items multi add - generate 'no_next_barcode' error if no barcode When multiple items added with barcode from the first, we expect for next barcode to be generated. If it will be the same barcode or empty one, then error 'no_next_barcode' will be generated to inform user/operator that operation wasn't completed as expected. --- cataloguing/additem.pl | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl index 2c371def28..8838e768f0 100755 --- a/cataloguing/additem.pl +++ b/cataloguing/additem.pl @@ -575,8 +575,15 @@ if ($op eq "additem") { # Getting a new barcode (if it is not the first iteration or the barcode we tried already exists) $barcodevalue = $barcodeobj->next_value($oldbarcode) if ($i > 0 || $exist_itemnumber); - # Putting it into the record - if ($barcodevalue) { + # if no barcode then let's generate the error "no_next_barcode", + # OR if barcode still the same after 'next_value', let's use this same error to prevent infinite loop: + if(! $barcodevalue or $barcodevalue eq $oldbarcode) { + push @errors, "no_next_barcode"; + $itemrecord = $record; + last; + } + # Putting it into the record + else { if ( C4::Context->preference("autoBarcode") eq 'hbyymmincr' && $i > 0 ) { # The first copy already contains the homebranch prefix # This is terribly hacky but the easiest way to fix the way hbyymmincr is working # Contrary to what one might think, the barcode plugin does not prefix the returned string with the homebranch @@ -614,7 +621,7 @@ if ($op eq "additem") { # Preparing the next iteration $oldbarcode = $barcodevalue; } - undef($itemrecord); + undef($itemrecord) if ! @errors; } } if ($frameworkcode eq 'FA' && $fa_circborrowernumber){ -- 2.17.1