Bug 27526: Fix Add & duplicate
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 9 Jul 2021 08:00:05 +0000 (10:00 +0200)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 6 Oct 2021 09:44:22 +0000 (11:44 +0200)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
cataloguing/additem.pl

index 3869bb1..a69ddd1 100755 (executable)
@@ -424,6 +424,7 @@ my $prefillitem = C4::Context->preference('PrefillItem');
 if ($op eq "additem") {
 
     my $add_submit                 = $input->param('add_submit');
+    my $add_duplicate_submit       = $input->param('add_duplicate_submit');
     my $add_multiple_copies_submit = $input->param('add_multiple_copies_submit');
     my $number_of_copies           = $input->param('number_of_copies');
 
@@ -499,7 +500,7 @@ if ($op eq "additem") {
     }
 
     # If we have to add & duplicate
-    if ($prefillitem) {
+    if ($prefillitem || $add_duplicate_submit) {
 
         $current_item = $item->unblessed;
 
@@ -511,6 +512,10 @@ if ($op eq "additem") {
             # we have to clear the barcode field in the duplicate item record to make way for the new one generated by the javascript plugin
             $current_item->{barcode} = undef; # FIXME or delete?
         }
+
+        # Don't use the "prefill" feature if we want to generate the form with all the info from this item
+        # It will remove subfields that are not in SubfieldsToUseWhenPrefill.
+        $prefillitem = 0 if $add_duplicate_submit;
     }
 
     # If we have to add multiple copies