Bug 21599: Fix item type creation by defining default values

Same as what we have in Koha::Patron->new, empty strings should not be
inserted in integer or date column type

DBD::mysql::st execute failed: Incorrect decimal value: '' for column 'defaultreplacecost' at row 1 [for Statement "INSERT INTO `itemtypes` ( `checkinmsg`, `checkinmsgtype`, `defaultreplacecost`, `description`, `hideinopac`, `imageurl`, `itemtype`, `notforloan`, `processfee`, `rentalcharge`, `searchcategory`, `sip_media_type`, `summary`) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" with ParamValues: 0="", 1="message", 2="", 3="xx", 4=0, 5='', 6="XX", 7=0, 8="", 9="", 10="", 11=undef, 12=""] at /usr/share/perl5/DBIx/Class/Storage/DBI.pm line 1832.

Test plan:
Create a new itemtype

Signed-off-by: Claire Gravely <claire.gravely@bsz-bw.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
(cherry picked from commit 33c142ba3b)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Jonathan Druart 2018-10-18 08:32:59 -03:00 committed by Martin Renvoize
parent 286b453d3a
commit 6c2eeaa434
No known key found for this signature in database
GPG Key ID: 422B469130441A0F
1 changed files with 12 additions and 0 deletions

View File

@ -36,6 +36,18 @@ Koha::ItemType - Koha Item type Object class
=cut
sub store {
my ($self) = @_;
$self->rentalcharge(undef) if $self->rentalcharge eq '';
$self->defaultreplacecost(undef) if $self->defaultreplacecost eq '';
$self->processfee(undef) if $self->processfee eq '';
$self->notforloan(0) unless $self->notforloan;
$self->hideinopac(0) unless $self->hideinopac;
return $self->SUPER::store;
}
=head3 image_location
=cut