diff --git a/Koha/Patron/Attribute.pm b/Koha/Patron/Attribute.pm index 26fffeb788..e453a4328a 100644 --- a/Koha/Patron/Attribute.pm +++ b/Koha/Patron/Attribute.pm @@ -146,13 +146,16 @@ sub _check_repeatable { my $self = shift; if ( !$self->type->repeatable ) { - my $attr_count = Koha::Patron::Attributes->search( - { borrowernumber => $self->borrowernumber, - code => $self->code - } - )->count; + my $params = { + borrowernumber => $self->borrowernumber, + code => $self->code + }; + + $params->{id} = { '!=' => $self->id } + if $self->in_storage; + Koha::Exceptions::Patron::Attribute::NonRepeatable->throw( attribute => $self ) - if $attr_count > 0; + if Koha::Patron::Attributes->search($params)->count > 0; } return $self;