Bug 23851: Add the homebranch prefix to the barcode when adding multiple copies of an items
See the comment in the code for more information. Test plan: - Set autoBarcode to hbyymmincr - Create an item and click on the barcode field - A barcode prefixed by the homebranch is generated - Click the "Add multiple copies of this item" and enter 4 - Save => Without this patch only the first item has the homebranch prefix => With this patch applied they all have a barcode in the same format Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
parent
a74f1dabe2
commit
aae3dfe123
1 changed files with 11 additions and 1 deletions
|
@ -577,7 +577,17 @@ if ($op eq "additem") {
|
|||
|
||||
# Putting it into the record
|
||||
if ($barcodevalue) {
|
||||
$record->field($tagfield)->update($tagsubfield => $barcodevalue);
|
||||
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
|
||||
# For a single item, it is handled with some JS code (see cataloguing/value_builder/barcode.pl)
|
||||
# But when adding multiple copies we need to prefix it here,
|
||||
# so we retrieve the homebranch from the item and prefix the barcode with it.
|
||||
my ($hb_field, $hb_subfield) = GetMarcFromKohaField( "items.homebranch" );
|
||||
my $homebranch = $record->subfield($hb_field, $hb_subfield);
|
||||
$barcodevalue = $homebranch . $barcodevalue;
|
||||
}
|
||||
$record->field($tagfield)->update($tagsubfield => $barcodevalue);
|
||||
}
|
||||
|
||||
# Checking if the barcode already exists
|
||||
|
|
Loading…
Reference in a new issue