From 237b3f0bbb00e137855eab862b40862d3f10e7a3 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 18 Mar 2019 14:20:51 -0300 Subject: [PATCH] Bug 23463: Replace _set_derived_columns_for_add Remove the unique call to _set_derived_columns_for_add Even if design to deal with other values it only dealts with cn_sort --- C4/Items.pm | 1 - Koha/Item.pm | 11 ++++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/C4/Items.pm b/C4/Items.pm index ecbc551597..d4d21bd190 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -203,7 +203,6 @@ sub AddItem { $unlinked_item_subfields = shift; } - _set_derived_columns_for_add($item); $item->{'more_subfields_xml'} = _get_unlinked_subfields_xml($unlinked_item_subfields); my ( $itemnumber, $error ) = _koha_new_item( $item, $item->{barcode} ); diff --git a/Koha/Item.pm b/Koha/Item.pm index d2fd7937c2..52d56b5897 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -26,6 +26,7 @@ use Koha::Database; use Koha::DateUtils qw( dt_from_string ); use C4::Context; +use C4::ClassSource; # FIXME We would like to avoid that use Koha::Checkouts; use Koha::IssuingRules; @@ -66,8 +67,8 @@ sub store { $self->itype($self->biblio->biblioitem->itemtype); } + my $today = dt_from_string; unless ( $self->in_storage ) { #AddItem - my $today = dt_from_string; unless ( $self->permanent_location ) { $self->permanent_location($self->location); } @@ -78,6 +79,14 @@ sub store { $self->datelastseen($today); } + unless ( $self->dateaccessioned ) { + $self->dateaccessioned($today); + } + + if ( $self->itemcallnumber ) { # This could be improved, we should recalculate it only if changed + my $cn_sort = GetClassSort($self->cn_source, $self->itemcallnumber, ""); + $self->cn_sort($cn_sort); + } } unless ( $self->dateaccessioned ) { -- 2.11.0