From 0a9e66b907d63b3eaf54f7481ce1348bd3ba153c Mon Sep 17 00:00:00 2001 From: Baptiste Date: Mon, 25 Nov 2024 17:00:53 +0100 Subject: [PATCH] Bug 38528: Additional fields are not properly fetched in serial subscription details TEST PLAN: 1 - Create a subscription 2 - Add an additional value: Name: TEST Authorised value: None Repeatable: Not checked Marc field: 245$a for MARC21, 200$a for UNIMARC MARC field mode: get value from marc record Searchable: Not checked 3 - Go on subscription details -> it is not displayed. 4 - Try and edit the subscription, go to page 2 -> value is not displayed 5 - Save -> value is not displayed 6 - Apply patch On steps 3, 4, and 5, you can now see the title --- Koha/Object/Mixin/AdditionalFields.pm | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Koha/Object/Mixin/AdditionalFields.pm b/Koha/Object/Mixin/AdditionalFields.pm index 4c2e25afe20..713b2bed530 100644 --- a/Koha/Object/Mixin/AdditionalFields.pm +++ b/Koha/Object/Mixin/AdditionalFields.pm @@ -197,6 +197,7 @@ the field values 'value' for that field. Example where field_id = 2 is the only sub get_additional_field_values_for_template { my ($self) = @_; + $self->_update_marc_get_fields(); my $additional_field_ids = $self->additional_field_values->search( {}, { @@ -215,6 +216,29 @@ sub get_additional_field_values_for_template { return \%fields; } +=head3 _update_marc_get_fields + +Update additional field in db according to their marc value + + $self->_update_marc_get_fields() + +=cut + +sub _update_marc_get_fields { + my ($self) = @_; + my $tablename = $self->_result->table; + my @additional_fields = Koha::AdditionalFields->search( + { + tablename => $tablename, + marcfield_mode => 'get', + -not => { marcfield => undef }, + -not => { marcfield => '' } + } + )->get_column('id'); + my @additional_get_fields = map { { id => $_ } } @additional_fields; + $self->set_additional_fields( \@additional_get_fields ); +} + =head3 additional_field_values Returns additional field values -- 2.30.2