Bug 37710

Summary: Remove the marc link when removing an item from a bundle
Product: Koha Reporter: Baptiste Wojtkowski (bwoj) <baptiste.wojtkowski>
Component: CatalogingAssignee: Baptiste Wojtkowski (bwoj) <baptiste.wojtkowski>
Status: Needs Signoff --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: lucas, m.de.rooy
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Bug Depends on: 37996    
Bug Blocks: 38093    
Attachments: Bug 37710: Remove the marc link when removing an item from a bundle
Bug 37710: Add unit tests
Bug 37710: Remove the marc link when removing an item from a bundle

Description Baptiste Wojtkowski (bwoj) 2024-08-22 14:09:25 UTC
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.
Comment 1 Baptiste Wojtkowski (bwoj) 2024-09-20 15:06:55 UTC
Created attachment 171832 [details] [review]
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
Comment 2 Lucas Gass (lukeg) 2024-09-21 15:21:53 UTC
Can we get some unit tests to cover unlink_marc_host?
Comment 3 Baptiste Wojtkowski (bwoj) 2024-09-24 13:45:35 UTC
Created attachment 171933 [details] [review]
Bug 37710: Add unit tests
Comment 4 Baptiste Wojtkowski (bwoj) 2024-09-24 13:45:37 UTC
Created attachment 171934 [details] [review]
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 - Apply tests and prove t/db_dependent/Koha/Biblio.t -> should fail
2 - 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).
3 - 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")
4 - Check on the MARC that field 461 (UNIMARC) or 773 (MARC21) is
  propperly filled
5 - Remove the item from the bundle
6 - Check that the marc field is still there and remove it manually
7 - APPLY PATCH
8 - Repeat 2-5 -> the field should have been automatically removed
9 - Run tests -> should pass

Note: as for link_marc_host, tests assume you are using MARC21
Comment 5 Baptiste Wojtkowski (bwoj) 2024-09-24 13:47:21 UTC
Note : 
In order to prove the behavior properly, I had to create Bug 37996