Bugzilla – Attachment 137872 Details for
Bug 31179
Duplicate item is duplicating internal item fields
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31179: Don't copy invisible subfields when duplicating items
Bug-31179-Dont-copy-invisible-subfields-when-dupli.patch (text/plain), 4.69 KB, created by
Jonathan Druart
on 2022-07-19 14:11:03 UTC
(
hide
)
Description:
Bug 31179: Don't copy invisible subfields when duplicating items
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2022-07-19 14:11:03 UTC
Size:
4.69 KB
patch
obsolete
>From f7a48068047e79b73b8b84117740edb8ef203b64 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 19 Jul 2022 16:09:46 +0200 >Subject: [PATCH] Bug 31179: Don't copy invisible subfields when duplicating > items > >Duplicate item is intended to duplicate the visible cataloging fields of an item, however, >currently it is duplicating the complete internal record of the item > >To recreate: >1 - find an item in Koha staff client, copy the barcode >2 - Issue this item to a patron >3 - Return to the record >4 - Edit items >5 - Click 'Actions->Duplicate' for the item in question >6 - Save the item >7 - Note in the items table above for that 'Total checkouts' 'Due date' > etc. have not been copied to new item >--- > Koha/UI/Form/Builder/Item.pm | 14 +++++++- > cataloguing/additem.pl | 5 +++ > t/db_dependent/Koha/UI/Form/Builder/Item.t | 37 +++++++++++++++++++++- > 3 files changed, 54 insertions(+), 2 deletions(-) > >diff --git a/Koha/UI/Form/Builder/Item.pm b/Koha/UI/Form/Builder/Item.pm >index 5efe6ed7962..fde62ea4e19 100644 >--- a/Koha/UI/Form/Builder/Item.pm >+++ b/Koha/UI/Form/Builder/Item.pm >@@ -455,6 +455,14 @@ Flag to add an empty option to the library list. > > =back > >+=item ignore_invisible_subfields >+ >+Skip the subfields that are not visible on the editor. >+ >+When duplicating an item we do not want to retrieve the subfields that are hidden. >+ >+=back >+ > =cut > > sub edit_form { >@@ -469,6 +477,7 @@ sub edit_form { > my $prefill_with_default_values = $params->{prefill_with_default_values}; > my $branch_limit = $params->{branch_limit}; > my $default_branches_empty = $params->{default_branches_empty}; >+ my $ignore_invisible_subfields = $params->{ignore_invisible_subfields} || 0; > > my $libraries = > Koha::Libraries->search( {}, { order_by => ['branchname'] } )->unblessed; >@@ -500,6 +509,10 @@ sub edit_form { > if grep { $subfield->{kohafield} && $subfield->{kohafield} eq $_ } > @$kohafields_to_ignore; > >+ next >+ if $ignore_invisible_subfields >+ && ( $subfield->{hidden} > 4 || $subfield->{hidden} <= -4 ); >+ > my $readonly; > if ( > @$subfields_to_allow && !grep { >@@ -507,7 +520,6 @@ sub edit_form { > } @$subfields_to_allow > ) > { >- > next if $ignore_not_allowed_subfields; > $readonly = 1 if $restricted_edition; > } >diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl >index 7cf5c03660f..86aa0cf0098 100755 >--- a/cataloguing/additem.pl >+++ b/cataloguing/additem.pl >@@ -626,6 +626,11 @@ my $subfields = > ), > prefill_with_default_values => 1, > branch_limit => C4::Context->userenv->{"branch"}, >+ ( >+ $op eq 'dupeitem' >+ ? ( ignore_invisible_subfields => 1 ) >+ : () >+ ), > } > ); > >diff --git a/t/db_dependent/Koha/UI/Form/Builder/Item.t b/t/db_dependent/Koha/UI/Form/Builder/Item.t >index 369f9b03989..b5d2a1a7a5f 100755 >--- a/t/db_dependent/Koha/UI/Form/Builder/Item.t >+++ b/t/db_dependent/Koha/UI/Form/Builder/Item.t >@@ -16,7 +16,7 @@ > # along with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >-use Test::More tests => 7; >+use Test::More tests => 8; > use Data::Dumper qw( Dumper ); > use utf8; > >@@ -298,6 +298,41 @@ subtest 'subfields_to_allow & ignore_not_allowed_subfields' => sub { > is( $subfield, undef, "subfield that is not in the allow list is not returned" ); > }; > >+subtest 'ignore_invisible_subfields' => sub { >+ plan tests => 2; >+ >+ my $biblio = >+ $builder->build_sample_biblio( { value => { frameworkcode => '' } } ); >+ my $item = $builder->build_sample_item( >+ { >+ issues => 42, >+ } >+ ); >+ >+ # items.issues is mapped with 952$l >+ my $subfields = Koha::UI::Form::Builder::Item->new( >+ { >+ biblionumber => $biblio->biblionumber, >+ item => $item->unblessed, >+ } >+ )->edit_form; >+ ( my $subfield ) = grep { $_->{subfield} eq 'l' } @$subfields; >+ is( $subfield->{marc_value}->{value}, 42, 'items.issues copied' ); >+ >+ $subfields = Koha::UI::Form::Builder::Item->new( >+ { >+ biblionumber => $biblio->biblionumber, >+ item => $item->unblessed, >+ } >+ )->edit_form( >+ { >+ ignore_invisible_subfields => 1 >+ } >+ ); >+ ($subfield) = grep { $_->{subfield} eq 'l' } @$subfields; >+ is( $subfield->{marc_value}->{value}, >+ undef, 'items.issues not copied if ignore_invisible_subfields is passed' ); >+}; > > $cache->clear_from_cache("MarcStructure-0-"); > $cache->clear_from_cache("MarcStructure-1-"); >-- >2.25.1
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 31179
:
137872
|
137875
|
137876
|
137877
|
137881
|
137882
|
137883