From 2c41115c1fa225bada624793e2060234575daa45 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 31 Oct 2025 09:15:31 +0000 Subject: [PATCH] Bug 39438: Add DBIC schema relationships for agreement period additional fields This patch adds the required DBIx::Class relationship definitions to Koha::Schema::Result::ErmAgreementPeriod to support additional fields and extended attributes on agreement periods. Two has_many relationships are added: - additional_field_values: links to all additional field values - extended_attributes: alias for additional_field_values Signed-off-by: Martin Renvoize --- Koha/Schema/Result/ErmAgreementPeriod.pm | 33 ++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/Koha/Schema/Result/ErmAgreementPeriod.pm b/Koha/Schema/Result/ErmAgreementPeriod.pm index d7c74bacae8..47c256a961a 100644 --- a/Koha/Schema/Result/ErmAgreementPeriod.pm +++ b/Koha/Schema/Result/ErmAgreementPeriod.pm @@ -120,6 +120,39 @@ __PACKAGE__->belongs_to( # Created by DBIx::Class::Schema::Loader v0.07049 @ 2022-05-25 11:46:59 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:NCQpSw+rp/9B/yOrtLtK6g +__PACKAGE__->has_many( + "additional_field_values", + "Koha::Schema::Result::AdditionalFieldValue", + sub { + my ($args) = @_; + + return { + "$args->{foreign_alias}.record_id" => { -ident => "$args->{self_alias}.agreement_period_id" }, + + "$args->{foreign_alias}.field_id" => + { -in => \'(SELECT id FROM additional_fields WHERE tablename="erm_agreement_periods")' }, + }; + }, + { cascade_copy => 0, cascade_delete => 0 }, +); + +__PACKAGE__->has_many( + "extended_attributes", + "Koha::Schema::Result::AdditionalFieldValue", + sub { + my ($args) = @_; + + return { + "$args->{foreign_alias}.record_id" => { -ident => "$args->{self_alias}.agreement_period_id" }, + + "$args->{foreign_alias}.field_id" => + { -in => \'(SELECT id FROM additional_fields WHERE tablename="erm_agreement_periods")' }, + }; + }, + { cascade_copy => 0, cascade_delete => 0 }, +); + + =head2 koha_object_class Missing POD for koha_object_class. -- 2.34.1