diff --git a/Koha/Virtualshelf.pm b/Koha/Virtualshelf.pm
index 930c4d6239..1cb82a1c5c 100644
--- a/Koha/Virtualshelf.pm
+++ b/Koha/Virtualshelf.pm
@@ -360,8 +360,43 @@ sub transfer_ownership {
Koha::Exceptions::MissingParameter->throw("Mandatory parameter 'patron' missing")
unless $patron_id;
+ ## before we change the owner, collect some details
+ my $old_owner = Koha::Patrons->find( $self->owner );
+ my $new_owner = Koha::Patrons->find($patron_id);
+ my $library = $new_owner->library->unblessed;
+
+ ## first we change the owner
$self->remove_share($patron_id) if $self->is_private;
- return $self->set( { owner => $patron_id } )->store;
+ $self->set( { owner => $patron_id } )->store;
+
+ ## now we message the new owner
+ my $letter = C4::Letters::GetPreparedLetter(
+ module => 'lists',
+ letter_code => 'TRANSFER_OWNERSHIP',
+ branchcode => $library->{branchcode},
+ lang => $new_owner->lang || 'default',
+ objects => {
+ old_owner => $old_owner,
+ new_owner => $new_owner,
+ shelf => $self,
+ },
+ tables => {
+ 'branches' => $library->{branchcode},
+ },
+ message_transport_type => 'email',
+ );
+
+ if ($letter) {
+ my $message_id = C4::Letters::EnqueueLetter(
+ {
+ letter => $letter,
+ borrowernumber => $patron_id,
+ message_transport_type => 'email',
+ }
+ ) or warn "can't enqueue letter $letter";
+ }
+
+ return $self;
}
=head2 Internal methods
diff --git a/installer/data/mysql/en/mandatory/sample_notices.yml b/installer/data/mysql/en/mandatory/sample_notices.yml
index bbbd7417f6..3ca1a9aea5 100644
--- a/installer/data/mysql/en/mandatory/sample_notices.yml
+++ b/installer/data/mysql/en/mandatory/sample_notices.yml
@@ -1329,6 +1329,22 @@ tables:
- "[% branch.branchillemail %]"
- "[% branch.branchemail %]"
+ - module: lists
+ code: TRANSFER_OWNERSHIP
+ branchcode: ""
+ name: "Transfer ownership"
+ is_html: 1
+ title: "A list has been transferred to you"
+ message_transport_type: email
+ lang: default
+ content:
+ - "Dear [%- INCLUDE 'patron-title.inc' patron => new_owner -%],
"
+ - "
"
+ - "A public list, titled [% shelf.shelfname | html %], has been transferred to you[% IF ( old_owner ) %] by [%- INCLUDE 'patron-title.inc' patron => old_owner%][% IF ( old_owner.email ) %] ([% old_owner.email | html %])[% END %][% END %].
"
+ - "
"
+ - "Thank you
"
+ - "
"
+
- module: members
code: DISCHARGE
branchcode: ""
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt
index d24fa422b3..784d15d0f8 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt
@@ -194,6 +194,7 @@