Revision ae83d528
Von Kivitendo Admin vor etwa 8 Jahren hinzugefügt
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__ |
SL/DB/Price.pm | ||
---|---|---|
6 | 6 |
use strict; |
7 | 7 |
|
8 | 8 |
use SL::DB::MetaSetup::Price; |
9 |
use Rose::DB::Object::Helpers qw(clone); |
|
9 | 10 |
|
10 | 11 |
__PACKAGE__->meta->initialize; |
11 | 12 |
|
Auch abrufbar als: Unified diff
Neue Methode clone_and_reset_deep für Part