From 4013304ff653a8c122ff19a2e9ec4c3593ac63bb Mon Sep 17 00:00:00 2001 From: Thibaud Guillot Date: Fri, 29 Aug 2025 09:47:13 +0200 Subject: [PATCH] Bug 38509: Set correct transfer when a hold exists When you transfer a reserved item, a pop up appears. Depending on your action, if you choose to transfer the item anyway, the flow is not normal afterwards: - Item is not added to branchtransfers sql tables (so neither in "Transfer to receive" section) - It does not appear in the list under the transfer action - Its homebranch is immediately that of destination site Test plan: 1) Place hold on item specific or not, with pickup library different than current library for a real case 2) Transfer this item to another library (library choose for pickup for example) 3) You will see a pop up (with incorrect label destination) 4) After confirm it, pop up disappears and none transfer is saved in branchtransfers table (neither in 'transfer to receive' section) 5) On biblio page you will already see item with new homebranch 6) Apply this patch and restart_all 7) Perform the same action, place a hold then transfer item 8) Pop up shows now the correct label destination 9) Transfer will be correctly performed, appears in branchtransfers sql table and 'transfer to receive' section (for destination site). Also item homebranch does not changes until the destination site check in it. Sponsored-by: BibLibre Co-authored-by: bwoj - baptiste.wojtkowski@biblibre.com --- circ/branchtransfers.pl | 28 ++++++++++++++++--- .../prog/en/modules/circ/branchtransfers.tt | 4 +-- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/circ/branchtransfers.pl b/circ/branchtransfers.pl index d8852ad3348..fe37717fa95 100755 --- a/circ/branchtransfers.pl +++ b/circ/branchtransfers.pl @@ -83,6 +83,9 @@ my $tobranchcd = $query->param('tobranchcd') || ''; my $trigger = 'Manual'; my $ignoreRs = 0; +my $transferred; +my $barcode = $query->param('barcode'); +my @trsfitemloop; ############ # Deal with the requests.... if ( $op eq "cud-KillWaiting" ) { @@ -106,6 +109,27 @@ if ( $op eq "cud-KillWaiting" ) { $settransit = 1; $reqmessage = 1; $trigger = 'Reserve'; + + $barcode = barcodedecode($barcode) if $barcode; + ($transferred, $messages) = transferbook( + { + from_branch => C4::Context->userenv->{'branch'}, + to_branch => $tobranchcd, + barcode => $barcode, + ignore_reserves => $ignoreRs, + trigger => $trigger + } + ); + if ($transferred) { + $item = Koha::Items->find( { barcode => $barcode } ); + my %trsfitem; + my $frbranchcd = C4::Context->userenv->{'branch'}; + $trsfitem{item} = $item; + $trsfitem{counter} = 0; + $trsfitem{frombrcd} = $frbranchcd; + $trsfitem{tobrcd} = $tobranchcd; + push( @trsfitemloop, \%trsfitem ); + } } elsif ( $op eq 'cud-KillReserved' ) { my $biblionumber = $query->param('biblionumber'); my $reserve_id = $query->param('reserve_id'); @@ -118,10 +142,6 @@ if ( $op eq "cud-KillWaiting" ) { } # collect the stack of books already transferred so they can printed... -my @trsfitemloop; -my $transferred; -my $barcode = $query->param('barcode'); - # remove leading/trailing whitespace $barcode = barcodedecode($barcode) if $barcode; if ( $op eq 'cud-transfer' && $barcode ) { diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/branchtransfers.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/branchtransfers.tt index 56dd9901695..656d3e766c6 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/branchtransfers.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/branchtransfers.tt @@ -112,7 +112,7 @@
  • Patron's address is in doubt
  • [% END %] -

    Transfer to: [% Branches.GetName( hold.branchcode ) | html %]

    +

    Transfer to: [% Branches.GetName( tobranchcd ) | html %]

    [% END %] @@ -132,7 +132,7 @@ [% END %] [% IF ( reserved ) %] - + [% END %] -- 2.39.5