From 62852241430b9444acd600498fc51912f36a90e7 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 6 Feb 2020 15:06:07 +0100 Subject: [PATCH] Bug 23463: Fix cn_source for new item get_dirty_columns only work for existing items. This fixes t/db_dependent/ShelfBrowser.t Signed-off-by: Tomas Cohen Arazi Signed-off-by: Nick Clemens Signed-off-by: Martin Renvoize --- Koha/Item.pm | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/Koha/Item.pm b/Koha/Item.pm index 65b55558b1..67a2328415 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -76,14 +76,6 @@ sub store { $self->itype($self->biblio->biblioitem->itemtype); } - my %updated_columns = $self->_result->get_dirty_columns; - if ( exists $updated_columns{itemcallnumber} - or exists $updated_columns{cn_source} ) - { - my $cn_sort = GetClassSort( $self->cn_source, $self->itemcallnumber, "" ); - $self->cn_sort($cn_sort); - } - my $today = dt_from_string; unless ( $self->in_storage ) { #AddItem unless ( $self->permanent_location ) { @@ -100,6 +92,13 @@ sub store { $self->dateaccessioned($today); } + if ( $self->itemcallnumber + or $self->cn_source ) + { + my $cn_sort = GetClassSort( $self->cn_source, $self->itemcallnumber, "" ); + $self->cn_sort($cn_sort); + } + C4::Biblio::ModZebra( $self->biblionumber, "specialUpdate", "biblioserver" ); logaction( "CATALOGUING", "ADD", $self->itemnumber, "item" ) @@ -138,8 +137,17 @@ sub store { } } - %updated_columns = $self->_result->get_dirty_columns; + my %updated_columns = $self->_result->get_dirty_columns; return $self->SUPER::store unless %updated_columns; + + if ( exists $updated_columns{itemcallnumber} + or exists $updated_columns{cn_source} ) + { + my $cn_sort = GetClassSort( $self->cn_source, $self->itemcallnumber, "" ); + $self->cn_sort($cn_sort); + } + + if ( exists $updated_columns{location} and $self->location ne 'CART' and $self->location ne 'PROC' -- 2.39.5