Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 6e1897a7

Von Kivitendo Admin vor etwa 8 Jahren hinzugefügt

  • ID 6e1897a72c16f0a5b397f5bfc26f9a554030dcc5
  • Vorgänger f3831ad9
  • Nachfolger 7a12fcf5

Neue Methode clone_and_reset_deep für Part

Unterschiede anzeigen:

SL/DB/Part.pm
247 247
  join ' ', grep $_, map $_[0]->$_, qw(partnumber description);
248 248
}
249 249

  
250
sub clone_and_reset_deep {
251
  my ($self) = @_;
252

  
253
  my $clone = $self->clone_and_reset; # resets id and partnumber (primary key and unique constraint)
254
  $clone->makemodels(       map { $_->clone_and_reset } @{$self->makemodels});
255
  $clone->translations(     map { $_->clone_and_reset } @{$self->translations});
256

  
257
  if ( $self->is_assortment ) {
258
    $clone->assortment_items( map { $_->clone } @{$self->assortment_items} );
259
      foreach my $ai ( @{ $clone->assortment_items } ) {
260
        $ai->assortment_id(undef);
261
      };
262
  };
263

  
264
  if ( $self->is_assembly ) {
265
    $clone->assemblies( map { $_->clone_and_reset } @{$self->assemblies});
266
  };
267

  
268
  if ( $self->prices ) {
269
    $clone->prices( map { $_->clone } @{$self->prices}); # pricegroup_id gets reset here because it is part of a unique contraint
270
    if ( $clone->prices ) {
271
      foreach my $price ( @{$clone->prices} ) {
272
        $price->id(undef);
273
        $price->parts_id(undef);
274
      };
275
    };
276
  };
277

  
278
  return $clone;
279
}
280

  
250 281
1;
251 282

  
252 283
__END__

Auch abrufbar als: Unified diff