Bug 25998: (QA follow-up) Add DBIC level relation
authorMartin Renvoize <martin.renvoize@ptfs-europe.com>
Fri, 17 Jul 2020 06:44:45 +0000 (07:44 +0100)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 22 Jul 2020 08:17:53 +0000 (10:17 +0200)
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Koha/Account/Line.pm
Koha/Schema/Result/Accountline.pm

index ce00de0..7ed59a9 100644 (file)
@@ -93,7 +93,7 @@ Returns a Koha::Library object representing where the accountline was recorded
 
 sub library {
     my ( $self ) = @_;
-    my $rs = $self->_result->branchcode;
+    my $rs = $self->_result->library;
     return unless $rs;
     return Koha::Library->_new_from_dbic($rs);
 }
index 12bb08c..2b14943 100644 (file)
@@ -370,6 +370,26 @@ __PACKAGE__->belongs_to(
 # Created by DBIx::Class::Schema::Loader v0.07046 @ 2020-03-19 09:20:20
 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:BuE4CYsSH4BwXZoQKE2MWw
 
+=head2 library
+
+Type: belongs_to
+
+Related object: L<Koha::Schema::Result::Branch>
+
+=cut
+
+__PACKAGE__->belongs_to(
+  "library",
+  "Koha::Schema::Result::Branch",
+  { branchcode => "branchcode" },
+  {
+    is_deferrable => 1,
+    join_type     => "LEFT",
+    on_delete     => "SET NULL",
+    on_update     => "CASCADE",
+  },
+);
+
 sub koha_objects_class {
     'Koha::Account::Lines';
 }