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 336-342 subtest 'pickup_locations' => sub { Link Here
336
};
336
};
337
337
338
subtest 'deletion' => sub {
338
subtest 'deletion' => sub {
339
    plan tests => 11;
339
    plan tests => 12;
340
340
341
    $schema->storage->txn_begin;
341
    $schema->storage->txn_begin;
342
342
Lines 424-429 subtest 'deletion' => sub { Link Here
424
424
425
    }
425
    }
426
426
427
    { # last_item_for_hold
428
        C4::Reserves::AddReserve($patron->branchcode, $patron->borrowernumber, $item->biblionumber );
429
        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' );
430
431
        # With another item attached to the biblio, the item can be deleted
432
        $builder->build_sample_item({ biblionumber => $item->biblionumber });
433
    }
434
427
    is(
435
    is(
428
        $item->safe_to_delete,
436
        $item->safe_to_delete,
429
        1,
437
        1,
430
- 

Return to bug 8132