From 2c1e0cd4e4f03a2eed19f7f09a88e662dc99fb18 Mon Sep 17 00:00:00 2001 From: Matt Blenkinsop Date: Mon, 15 Dec 2025 17:04:18 +0000 Subject: [PATCH] Bug 41451: Set correct embed and column property for itemtypes in the holds history table Test plan: 1) Create at least one hold on any record 2) Navigate to the patron who has the hold and click Holds history in the left menu 3) The table should load correctly and the search bar above it should work 4) In system preferences, enable AllowHoldItemTypeSelection 5) Refresh the holds history, the Requested item type column should now be visible 6) Try a search, a 500 error should be thrown 7) Apply patch and run yarn api:bundle && restart_all 8) Repeat step 5, the search should now work correctly --- Koha/Schema/Result/Item.pm | 7 +++++++ api/v1/swagger/paths/patrons_holds.yaml | 1 + .../intranet-tmpl/prog/en/modules/members/holdshistory.tt | 8 ++++---- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Koha/Schema/Result/Item.pm b/Koha/Schema/Result/Item.pm index 83b361a1400..cd102c796fd 100644 --- a/Koha/Schema/Result/Item.pm +++ b/Koha/Schema/Result/Item.pm @@ -1082,6 +1082,13 @@ __PACKAGE__->might_have( { cascade_copy => 0, cascade_delete => 0 }, ); +__PACKAGE__->belongs_to( + "itemtype", + "Koha::Schema::Result::Itemtype", + { "foreign.itemtype" => "self.itype" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + use C4::Context; =head2 effective_itemtype diff --git a/api/v1/swagger/paths/patrons_holds.yaml b/api/v1/swagger/paths/patrons_holds.yaml index b8c28f30d83..87a53ebe504 100644 --- a/api/v1/swagger/paths/patrons_holds.yaml +++ b/api/v1/swagger/paths/patrons_holds.yaml @@ -33,6 +33,7 @@ - biblio - deleted_biblio - item + - item.itemtype - pickup_library collectionFormat: csv produces: diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/holdshistory.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/holdshistory.tt index 3fa944bdcf0..31f49ee2378 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/holdshistory.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/holdshistory.tt @@ -203,7 +203,7 @@ }; let table_url = '/api/v1/patrons/[% patron.borrowernumber | uri %]/holds'; - let table_embeds = ['+strings', 'biblio', 'item', 'pickup_library']; + let table_embeds = ['+strings', 'biblio', 'item', 'item.itemtype', 'pickup_library']; if (old){ table_url += '?old=1'; table_embeds.push('deleted_biblio'); @@ -298,12 +298,12 @@ }, [% IF show_itemtype_column %] { - data: "item_type.item_type", + data: "item.itemtype.description", searchable: true, orderable: true, render: function (data, type, row, meta) { - if ( row.item_type ) { - return row.item_type.item_type; + if ( row.item?.itemtype ) { + return row.item.itemtype.description; } else { return _("Any item type"); } -- 2.39.5