Bugzilla – Attachment 171832 Details for
Bug 37710
Remove the marc link when removing an item from a bundle
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 37710: Remove the marc link when removing an item from a bundle
Bug-37710-Remove-the-marc-link-when-removing-an-it.patch (text/plain), 3.09 KB, created by
Baptiste Wojtkowski (bwoj)
on 2024-09-20 15:06:55 UTC
(
hide
)
Description:
Bug 37710: Remove the marc link when removing an item from a bundle
Filename:
MIME Type:
Creator:
Baptiste Wojtkowski (bwoj)
Created:
2024-09-20 15:06:55 UTC
Size:
3.09 KB
patch
obsolete
>From 23361a6bc5cd08387deb37102b8630f382568a4e Mon Sep 17 00:00:00 2001 >From: Baptiste Wojtkowski <bski@laposte.net> >Date: Fri, 20 Sep 2024 16:47:18 +0200 >Subject: [PATCH] Bug 37710: Remove the marc link when removing an item from a > bundle > >A new functionality to automatically add a new MARC link has been added in Bug 29560 (Add option to create MARC links when adding items to bundles). There should also be a way to remove this link when removing the item from the bundle. > >Moreover I don't know if this should be a second bug but since the link is not removed, there can be multiple links if the item is added to a new bundle. > >TEST PLAN: >1 - Create a bundle on an item by changing the 7th character of the > leader to c (go to the marc, click on the button at the right of the > field 000 and change the bibliographical level to collection). >2 - Add an item to the bundle (on the biblio, exemplars will have a > button "manage bundle"->add_to_bundle, fill in a barcode and check "add MARC link") >3 - Check on the MARC that field 461 (UNIMARC) or 773 (MARC21) is > propperly filled >4 - Remove the item from the bundle >5 - Check that the marc field is still there and remove it manually >6 - APPLY PATCH >7 - Repeat 2-5 -> the field should have been automatically removed >--- > Koha/Biblio.pm | 36 ++++++++++++++++++++++++++++++++++++ > Koha/REST/V1/Items.pm | 1 + > 2 files changed, 37 insertions(+) > >diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm >index 8029be8e..be6e8fd4 100644 >--- a/Koha/Biblio.pm >+++ b/Koha/Biblio.pm >@@ -1931,6 +1931,42 @@ sub generate_marc_host_field { > return $link_field; > } > >+ >+ >+=head3 unlink_marc_host >+ >+ $biblio->unlink_marc_host({ host => $biblio }); >+ $biblio->unlink_marc_host({ host => $biblionumber }); >+ >+Remove the link to the parent created by link_marc_host. Expects either the biblio object or biblionumber of the host to link to. >+ >+=cut >+ >+ >+sub unlink_marc_host { >+ my ( $self, $params ) = @_; >+ my $host_biblionumber; >+ if ( ref( $params->{host} ) eq 'Koha::Biblio' ) { >+ $host_biblionumber = $params->{host}->biblionumber; >+ } else { >+ $host_biblionumber = $params->{host}; >+ } >+ >+ my $record = $self->metadata->record; >+ my $field_number = C4::Context->preference('marcflavour') eq 'MARC21' ? '773' : '461'; >+ my @fields = $record->field($field_number); >+ >+ foreach my $field (@fields) { >+ my $subfield_biblionumber = $field->subfield('0') // q{}; >+ if ($host_biblionumber eq $subfield_biblionumber){ >+ $record->delete_field($field); >+ } >+ } >+ >+ C4::Biblio::ModBiblio($record, $self->biblionumber); >+} >+ >+ > =head3 link_marc_host > > $biblio->link_marc_host({ field => $link_field}); >diff --git a/Koha/REST/V1/Items.pm b/Koha/REST/V1/Items.pm >index 48468b68..cfa60e3b 100644 >--- a/Koha/REST/V1/Items.pm >+++ b/Koha/REST/V1/Items.pm >@@ -411,6 +411,7 @@ sub remove_from_bundle { > unless $bundle_item; > > return try { >+ $bundle_item->biblio->unlink_marc_host({ host => $item->biblio }); > $bundle_item->remove_from_bundle; > return $c->render_resource_deleted; > } catch { >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 37710
:
171832
|
171933
|
171934