X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FController%2FCsvImport%2FPart.pm;h=9afaf637c4a0649e1fed108bdf324eb3cc0c8afd;hb=c48270dd341297d7a1f70fd7cb48683c011213f2;hp=f04e7d63282979ff5943361a23ac5c94903de95a;hpb=a7f02ca024d1fb4154c31381600081f7a7bf4039;p=kivitendo-erp.git diff --git a/SL/Controller/CsvImport/Part.pm b/SL/Controller/CsvImport/Part.pm index f04e7d632..9afaf637c 100644 --- a/SL/Controller/CsvImport/Part.pm +++ b/SL/Controller/CsvImport/Part.pm @@ -175,7 +175,7 @@ sub check_objects { $self->handle_prices($entry) if $self->settings->{sellprice_adjustment}; $self->handle_shoparticle($entry); $self->handle_translations($entry); - $self->handle_cvars($entry); + $self->handle_cvars($entry) unless $entry->{dont_handle_cvars}; $self->handle_makemodel($entry); $self->set_various_fields($entry); } continue { @@ -320,7 +320,8 @@ sub check_existing { $entry->{part}->prices(grep { $_ } map { $prices_by_pricegroup_id{$_->id} } @{ $self->all_pricegroups }); push @{ $entry->{information} }, $::locale->text('Updating prices of existing entry in database'); - $entry->{object_to_save} = $entry->{part}; + $entry->{object_to_save} = $entry->{part}; + $entry->{dont_handle_cvars} = 1; } elsif ( $self->settings->{article_number_policy} eq 'update_parts' || $self->settings->{article_number_policy} eq 'update_parts_sn') { # Update parts table @@ -355,24 +356,6 @@ sub check_existing { } $entry->{part}->translations(\@translations) if @translations; - # Update cvars - my %type_to_column = ( text => 'text_value', - textfield => 'text_value', - select => 'text_value', - date => 'timestamp_value_as_date', - timestamp => 'timestamp_value_as_date', - number => 'number_value_as_number', - bool => 'bool_value' ); - my @cvars; - push @cvars, $entry->{part}->custom_variables; - foreach my $config (@{ $self->all_cvar_configs }) { - next unless exists $raw->{ "cvar_" . $config->name }; - my $value = $raw->{ "cvar_" . $config->name }; - my $column = $type_to_column{ $config->type } || die "Program logic error: unknown custom variable storage type"; - push @cvars, SL::DB::CustomVariable->new(config_id => $config->id, $column => $value, sub_module => ''); - } - $entry->{part}->custom_variables(\@cvars) if @cvars; - # save Part Update push @{ $entry->{information} }, $::locale->text('Updating data of existing entry in database'); @@ -561,7 +544,7 @@ sub check_partsgroup { # Check whether or not part group ID is valid. if ($object->partsgroup_id && !$self->partsgroups_by->{id}->{ $object->partsgroup_id }) { - push @{ $entry->{errors} }, $::locale->text('Error: Invalid parts group'); + push @{ $entry->{errors} }, $::locale->text('Error: Invalid parts group id #1', $object->partsgroup_id); return 0; } @@ -570,7 +553,7 @@ sub check_partsgroup { my $pg = $self->partsgroups_by->{partsgroup}->{ $entry->{raw_data}->{partsgroup} }; if (!$pg) { - push @{ $entry->{errors} }, $::locale->text('Error: Invalid parts group'); + push @{ $entry->{errors} }, $::locale->text('Error: Invalid parts group name #1', $entry->{raw_data}->{partsgroup}); return 0; } @@ -680,7 +663,7 @@ sub handle_makemodel { } } - $entry->{part}->makemodels([ $entry->{part}->makemodels_sorted, @new_makemodels ]) if @new_makemodels; + $entry->{part}->makemodels([ @{$entry->{part}->makemodels_sorted}, @new_makemodels ]) if @new_makemodels; # reindex makemodels my $i = 0; @@ -692,7 +675,9 @@ sub handle_makemodel { sub set_various_fields { my ($self, $entry) = @_; - $entry->{object}->priceupdate(DateTime->now_local); + my $object = $entry->{object_to_save} || $entry->{object}; + + $object->priceupdate(DateTime->now_local); } sub init_profile { @@ -713,7 +698,6 @@ sub save_objects { my $without_number = [ grep { $_->{object}->partnumber eq '####' } @{ $self->controller->data } ]; map { $_->{object}->partnumber('') } @{ $without_number }; - $self->SUPER::save_objects(data => $with_number); $self->SUPER::save_objects(data => $without_number); }