View | Details | Raw Unified | Return to bug 8132
Collapse All | Expand All

(-)a/Koha/Item.pm (+10 lines)
Lines 220-225 returns 1 if the item is safe to delete, Link Here
220
220
221
"linked_analytics" if the item has linked analytic records.
221
"linked_analytics" if the item has linked analytic records.
222
222
223
"last_item_for_hold" if the item is the last one on a record on which a biblio-level hold is placed
224
223
=cut
225
=cut
224
226
225
sub safe_to_delete {
227
sub safe_to_delete {
Lines 240-245 sub safe_to_delete { Link Here
240
    return "linked_analytics"
242
    return "linked_analytics"
241
      if C4::Items::GetAnalyticsCount( $self->itemnumber ) > 0;
243
      if C4::Items::GetAnalyticsCount( $self->itemnumber ) > 0;
242
244
245
    return "last_item_for_hold"
246
      if $self->biblio->items->count == 1
247
      && $self->biblio->holds->search(
248
          {
249
              itemnumber => undef,
250
          }
251
        )->count;
252
243
    return 1;
253
    return 1;
244
}
254
}
245
255
(-)a/t/db_dependent/Koha/Item.t (-2 / +9 lines)
Lines 333-339 subtest 'pickup_locations' => sub { Link Here
333
};
333
};
334
334
335
subtest 'deletion' => sub {
335
subtest 'deletion' => sub {
336
    plan tests => 11;
336
    plan tests => 12;
337
337
338
    $schema->storage->txn_begin;
338
    $schema->storage->txn_begin;
339
339
Lines 421-426 subtest 'deletion' => sub { Link Here
421
421
422
    }
422
    }
423
423
424
    { # last_item_for_hold
425
        C4::Reserves::AddReserve($patron->branchcode, $patron->borrowernumber, $item->biblionumber );
426
        is( $item->safe_to_delete, 'last_item_for_hold', 'Item cannot be deleted if a biblio-level is placed on the biblio and there is only 1 item attached to the biblio' );
427
428
        # With another item attached to the biblio, the item can be deleted
429
        $builder->build_sample_item({ biblionumber => $item->biblionumber });
430
    }
431
424
    is(
432
    is(
425
        $item->safe_to_delete,
433
        $item->safe_to_delete,
426
        1,
434
        1,
427
- 

Return to bug 8132