CsvImport/Parts: makemodels fix inidzieren
authorSven Schöling <s.schoeling@linet-services.de>
Wed, 24 Sep 2014 09:12:38 +0000 (11:12 +0200)
committerSven Schöling <s.schoeling@linet-services.de>
Wed, 24 Sep 2014 09:12:38 +0000 (11:12 +0200)
SL/Controller/CsvImport/Part.pm

index 7637932..75adc97 100644 (file)
@@ -436,13 +436,16 @@ sub handle_makemodel {
     if ($makemodel_orig) {
       $makemodel_orig->model($makemodel->model);
       $makemodel_orig->lastcost($makemodel->lastcost);
-      $makemodel_orig->sortorder(undef);
 
     } else {
       $entry->{part}->add_makemodels($makemodel);
     }
   }
 
+  # reindex makemodels
+  my $i = 0;
+  $_->sortorder(++$i) for @{ $entry->{part}->makemodels };
+
   $entry->{part}->makemodel($object->makemodel);
 
   $self->save_with_cascade(1) if $found_any;