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

(-)a/Koha/Item.pm (-9 / +9 lines)
Lines 89-96 sub store { Link Here
89
        $self->itype($self->biblio->biblioitem->itemtype);
89
        $self->itype($self->biblio->biblioitem->itemtype);
90
    }
90
    }
91
91
92
    my $today         = dt_from_string;
92
    my $today  = dt_from_string;
93
    my $plugin_action = 'create';
93
    my $action = 'create';
94
94
95
    unless ( $self->in_storage ) { #AddItem
95
    unless ( $self->in_storage ) { #AddItem
96
        unless ( $self->permanent_location ) {
96
        unless ( $self->permanent_location ) {
Lines 114-125 sub store { Link Here
114
            $self->cn_sort($cn_sort);
114
            $self->cn_sort($cn_sort);
115
        }
115
        }
116
116
117
        logaction( "CATALOGUING", "ADD", $self->itemnumber, "item" )
118
          if $log_action && C4::Context->preference("CataloguingLog");
119
120
    } else { # ModItem
117
    } else { # ModItem
121
118
122
        $plugin_action = 'modify';
119
        $action = 'modify';
123
120
124
        my %updated_columns = $self->_result->get_dirty_columns;
121
        my %updated_columns = $self->_result->get_dirty_columns;
125
        return $self->SUPER::store unless %updated_columns;
122
        return $self->SUPER::store unless %updated_columns;
Lines 186-193 sub store { Link Here
186
            $self->_set_found_trigger($pre_mod_item);
183
            $self->_set_found_trigger($pre_mod_item);
187
        }
184
        }
188
185
189
        logaction( "CATALOGUING", "MODIFY", $self->itemnumber, "item " . Dumper($self->unblessed) )
190
          if $log_action && C4::Context->preference("CataloguingLog");
191
    }
186
    }
192
187
193
    unless ( $self->dateaccessioned ) {
188
    unless ( $self->dateaccessioned ) {
Lines 195-204 sub store { Link Here
195
    }
190
    }
196
191
197
    my $result = $self->SUPER::store;
192
    my $result = $self->SUPER::store;
193
    if ( $log_action && C4::Context->preference("CataloguingLog") ) {
194
        $action eq 'create'
195
          ? logaction( "CATALOGUING", "ADD", $self->itemnumber, "item" )
196
          : logaction( "CATALOGUING", "MODIFY", $self->itemnumber, "item " . Dumper( $self->unblessed ) );
197
    }
198
    my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX });
198
    my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX });
199
    $indexer->index_records( $self->biblionumber, "specialUpdate", "biblioserver" )
199
    $indexer->index_records( $self->biblionumber, "specialUpdate", "biblioserver" )
200
        unless $params->{skip_record_index};
200
        unless $params->{skip_record_index};
201
    $self->get_from_storage->_after_item_action_hooks({ action => $plugin_action });
201
    $self->get_from_storage->_after_item_action_hooks({ action => $action });
202
202
203
    return $result;
203
    return $result;
204
}
204
}
(-)a/t/db_dependent/Koha/Items.t (-2 / +40 lines)
Lines 65-71 my $retrieved_item_1 = Koha::Items->find( $new_item_1->itemnumber ); Link Here
65
is( $retrieved_item_1->barcode, $new_item_1->barcode, 'Find a item by id should return the correct item' );
65
is( $retrieved_item_1->barcode, $new_item_1->barcode, 'Find a item by id should return the correct item' );
66
66
67
subtest 'store' => sub {
67
subtest 'store' => sub {
68
    plan tests => 6;
68
    plan tests => 7;
69
69
70
    my $biblio = $builder->build_sample_biblio;
70
    my $biblio = $builder->build_sample_biblio;
71
    my $today  = dt_from_string->set( hour => 0, minute => 0, second => 0 );
71
    my $today  = dt_from_string->set( hour => 0, minute => 0, second => 0 );
Lines 1140-1145 subtest 'store' => sub { Link Here
1140
1140
1141
        };
1141
        };
1142
    };
1142
    };
1143
1144
    subtest 'log_action' => sub {
1145
        plan tests => 2;
1146
        t::lib::Mocks::mock_preference( 'CataloguingLog', 1 );
1147
1148
        my $item = Koha::Item->new(
1149
            {
1150
                homebranch    => $library->{branchcode},
1151
                holdingbranch => $library->{branchcode},
1152
                biblionumber  => $biblio->biblionumber,
1153
                location      => 'my_loc',
1154
            }
1155
        )->store;
1156
        is(
1157
            Koha::ActionLogs->search(
1158
                {
1159
                    module => 'CATALOGUING',
1160
                    action => 'ADD',
1161
                    object => $item->itemnumber,
1162
                    info   => 'item'
1163
                }
1164
            )->count,
1165
            1,
1166
            "Item creation logged"
1167
        );
1168
1169
        $item->location('another_loc')->store;
1170
        is(
1171
            Koha::ActionLogs->search(
1172
                {
1173
                    module => 'CATALOGUING',
1174
                    action => 'MODIFY',
1175
                    object => $item->itemnumber
1176
                }
1177
            )->count,
1178
            1,
1179
            "Item modification logged"
1180
        );
1181
    };
1143
};
1182
};
1144
1183
1145
subtest 'get_transfer' => sub {
1184
subtest 'get_transfer' => sub {
1146
- 

Return to bug 27003