From 02515ebcc764345d0c7705dbada97d7755e97291 Mon Sep 17 00:00:00 2001 From: Emmi Takkinen Date: Thu, 6 Aug 2026 13:37:13 +0300 Subject: [PATCH] Bug 43239: Preserve item item type if previousitemtype column is undefined It is possible to create serial item with wrong itemtype if syspreference makePreviousSerialAvailable is enabled and field "item type for older issues" isn't filled when creating a subscription for biblio record. This happens when multiple items are created. In installations where itemtypes differ between items and biblios, this causes data inconsistencies and leads to errors in biblios Holdings table. This patch changes behaviour of serials-edit.pl so that if makePreviousSerialAvailable is enabled and subscriptions previousitemtype column is NULL, previous serial items itype column is preserved. It also adds a hint text to subscription form about this change. To test: 1. Enable systempreference makePreviousSerialAvailable. 2. Create new biblio record. 3. Create a new subscription for biblio record you made, select option "Create an item record", select different item type from "Item type" selection than biblio record has but leave selection "item type for older issues" empty. 4. Receive a serial item for subscription. Check from biblio records Holdings table that its item type matches item type selected in step 3. 5. Now receive 3 serial items. After creating them check Holdings table again. => Note that first item created now has same item type as biblio record. 6. Apply this patch, restart services. 7. Create new subscription, fill needed fields as in step 3. => Note that there is a new hint text after field "item type for older issues". 8. Repeat steps 4. and 5. => Note that now all items have same item type. Sponsored-by: Koha-Suomi Oy Signed-off-by: David Nind Signed-off-by: Katrin Fischer Signed-off-by: Pedro Amorim --- .../prog/en/modules/serials/subscription-add.tt | 3 ++- serials/serials-edit.pl | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt index 128b8c87ed..b2a9db7fcf 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt @@ -245,7 +245,7 @@ [% IF makePreviousSerialAvailable %]
  • - + +
    If older issues itemtype is not selected old item type is preserved.
  • [% END %]
  • diff --git a/serials/serials-edit.pl b/serials/serials-edit.pl index 382b485789..d824d7c83e 100755 --- a/serials/serials-edit.pl +++ b/serials/serials-edit.pl @@ -260,10 +260,14 @@ if ( $op and $op eq 'cud-serialchangestatus' ) { # Changing the status to "available" and the itemtype according to the previousitemtype db field my $item = Koha::Items->find($itemnumber); + my $itype = + $subscriptioninfos->{'previousitemtype'} + ? $subscriptioninfos->{'previousitemtype'} + : $item->itype; $item->set( { notforloan => 0, - itype => $subscriptioninfos->{'previousitemtype'} + itype => $itype } )->store; }