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

(-)a/Koha/Item.pm (+10 lines)
Lines 234-239 returns 1 if the item is safe to delete, Link Here
234
234
235
"linked_analytics" if the item has linked analytic records.
235
"linked_analytics" if the item has linked analytic records.
236
236
237
"last_item_for_hold" if the item is the last one on a record on which a biblio-level hold is placed
238
237
=cut
239
=cut
238
240
239
sub safe_to_delete {
241
sub safe_to_delete {
Lines 254-259 sub safe_to_delete { Link Here
254
    return "linked_analytics"
256
    return "linked_analytics"
255
      if C4::Items::GetAnalyticsCount( $self->itemnumber ) > 0;
257
      if C4::Items::GetAnalyticsCount( $self->itemnumber ) > 0;
256
258
259
    return "last_item_for_hold"
260
      if $self->biblio->items->count == 1
261
      && $self->biblio->holds->search(
262
          {
263
              itemnumber => undef,
264
          }
265
        )->count;
266
257
    return 1;
267
    return 1;
258
}
268
}
259
269
(-)a/t/db_dependent/Koha/Item.t (-2 / +9 lines)
Lines 342-348 subtest 'pickup_locations' => sub { Link Here
342
};
342
};
343
343
344
subtest 'deletion' => sub {
344
subtest 'deletion' => sub {
345
    plan tests => 11;
345
    plan tests => 12;
346
346
347
    $schema->storage->txn_begin;
347
    $schema->storage->txn_begin;
348
348
Lines 430-435 subtest 'deletion' => sub { Link Here
430
430
431
    }
431
    }
432
432
433
    { # last_item_for_hold
434
        C4::Reserves::AddReserve($patron->branchcode, $patron->borrowernumber, $item->biblionumber );
435
        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' );
436
437
        # With another item attached to the biblio, the item can be deleted
438
        $builder->build_sample_item({ biblionumber => $item->biblionumber });
439
    }
440
433
    is(
441
    is(
434
        $item->safe_to_delete,
442
        $item->safe_to_delete,
435
        1,
443
        1,
436
- 

Return to bug 8132