@@ -, +, @@ biblio<->biblioitem<->item --- Koha/Item.pm | 9 +++++++ Koha/Schema/Result/Biblioitem.pm | 2 +- Koha/Schema/Result/Item.pm | 2 ++ .../prog/en/modules/circ/circulation.tt | 2 +- t/db_dependent/Schema.t | 31 ++++++++++++++++++++++ 5 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 t/db_dependent/Schema.t --- a/Koha/Item.pm +++ a/Koha/Item.pm @@ -37,6 +37,15 @@ Koha::Item - Koha Item object class =cut +=head3 biblioitem + +=cut + +sub biblioitem { + my ( $self ) = @_; + return $self->_result->biblioitem; +} + =head3 effective_itemtype Returns the itemtype for the item based on whether item level itemtypes are set or not. --- a/Koha/Schema/Result/Biblioitem.pm +++ a/Koha/Schema/Result/Biblioitem.pm @@ -344,6 +344,6 @@ __PACKAGE__->has_many( # Created by DBIx::Class::Schema::Loader v0.07039 @ 2015-02-24 14:19:57 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:A/4lKYlKWWd8TcMVzMRtCg +__PACKAGE__->belongs_to( biblio => "Koha::Schema::Result::Biblio", "biblionumber" ); -# You can replace this text with custom content, and it will be preserved on regeneration 1; --- a/Koha/Schema/Result/Item.pm +++ a/Koha/Schema/Result/Item.pm @@ -619,6 +619,8 @@ __PACKAGE__->might_have( # Created by DBIx::Class::Schema::Loader v0.07039 @ 2015-04-23 12:42:12 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:urSpNt7LBda4T5Plhi6cPw +__PACKAGE__->belongs_to( biblioitem => "Koha::Schema::Result::Biblioitem", "biblioitemnumber" ); + sub effective_itemtype { my ( $self ) = @_; --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -675,7 +675,7 @@ No patron matched [% message %] [% IF ( issue ) %]
-

Checked out: [% issue.item.biblioitemnumber.biblionumber.title %] ([% issue.item.barcode %]). Due on [% issue.date_due | $KohaDates %]

+

Checked out: [% issue.item.biblioitem.biblio.title %] ([% issue.item.barcode %]). Due on [% issue.date_due | $KohaDates %]

[% END %] --- a/t/db_dependent/Schema.t +++ a/t/db_dependent/Schema.t @@ -0,0 +1,31 @@ +use Modern::Perl; +use Test::More tests => 1; + +use t::lib::TestBuilder; + +use Koha::Biblios; +use Koha::Items; + +my $builder = t::lib::TestBuilder->new; + +subtest 'item->biblioitem' => sub { + plan tests => 1; + + # NOTE This is a trick, if we want to populate the biblioitems table, we should not create a Biblio but a Biblioitem + my $biblio = $builder->build( { source => 'Biblioitem', } )->{_fk}{biblionumber}; + my $item1 = $builder->build( + { source => 'Item', + value => { biblionumber => $biblio->{biblionumber}, biblioitemnumber => $biblio->{biblionumber} }, + } + ); + my $item2 = $builder->build( + { source => 'Item', + value => { biblionumber => $biblio->{biblionumber}, biblioitemnumber => $biblio->{biblionumber} }, + } + ); + + my $biblio_object = Koha::Biblios->find( $biblio->{biblionumber} ); + my $item_object = Koha::Items->find( $item1->{itemnumber} ); + + is( $item_object->biblioitem->biblio->biblionumber, $biblio->{biblionumber} ); +}; --