Revision 64031f04
Von Jan Büren vor etwa 2 Jahren hinzugefügt
SL/Controller/Part.pm | ||
---|---|---|
238 | 238 |
$::form->{oldpartnumber} = $oldpart->partnumber; |
239 | 239 |
|
240 | 240 |
$self->part($oldpart->clone_and_reset_deep); |
241 |
$self->parse_form; |
|
241 |
$self->parse_form(use_as_new => 1);
|
|
242 | 242 |
$self->part->partnumber(undef); |
243 |
|
|
244 |
$self->render_form; |
|
243 |
$self->render_form(use_as_new => 1); |
|
245 | 244 |
} |
246 | 245 |
|
247 | 246 |
sub action_edit { |
... | ... | |
260 | 259 |
%assortment_vars = %{ $self->prepare_assortment_render_vars } if $self->part->is_assortment; |
261 | 260 |
%assembly_vars = %{ $self->prepare_assembly_render_vars } if $self->part->is_assembly; |
262 | 261 |
|
263 |
$params{CUSTOM_VARIABLES} = CVar->get_custom_variables(module => 'IC', trans_id => $self->part->id); |
|
262 |
$params{CUSTOM_VARIABLES} = $params{use_as_new} && $::form->{old_id} |
|
263 |
? CVar->get_custom_variables(module => 'IC', trans_id => $::form->{old_id}) |
|
264 |
: CVar->get_custom_variables(module => 'IC', trans_id => $self->part->id); |
|
265 |
|
|
264 | 266 |
|
265 | 267 |
if (scalar @{ $params{CUSTOM_VARIABLES} }) { |
266 | 268 |
CVar->render_inputs('variables' => $params{CUSTOM_VARIABLES}, show_disabled_message => 1, partsgroup_id => $self->part->partsgroup_id); |
... | ... | |
787 | 789 |
} |
788 | 790 |
|
789 | 791 |
sub parse_form { |
790 |
my ($self) = @_; |
|
792 |
my ($self, %params) = @_;
|
|
791 | 793 |
|
792 | 794 |
my $is_new = !$self->part->id; |
793 | 795 |
|
... | ... | |
812 | 814 |
$self->part->add_assemblies( @{ $self->assembly_items } ); |
813 | 815 |
}; |
814 | 816 |
|
815 |
$self->part->translations([]); |
|
817 |
$self->part->translations([]) unless $params{use_as_new};
|
|
816 | 818 |
$self->parse_form_translations; |
817 | 819 |
|
818 | 820 |
$self->part->prices([]); |
SL/DB/Part.pm | ||
---|---|---|
470 | 470 |
my $clone = $self->clone_and_reset; # resets id and partnumber (primary key and unique constraint) |
471 | 471 |
$clone->makemodels( map { $_->clone_and_reset } @{$self->makemodels} ) if @{$self->makemodels}; |
472 | 472 |
$clone->translations( map { $_->clone_and_reset } @{$self->translations} ) if @{$self->translations}; |
473 |
|
|
473 |
$clone->custom_variables( map { $_->clone_and_reset } @{$self->custom_variables} ) if @{$self->custom_variables}; |
|
474 | 474 |
if ( $self->is_assortment ) { |
475 | 475 |
# use clone rather than reset_and_clone because the unique constraint would also remove parts_id |
476 | 476 |
$clone->assortment_items( map { $_->clone } @{$self->assortment_items} ); |
Auch abrufbar als: Unified diff
Artikel als neu Speichern auch BDVs und Übersetzungen vom Vorgänger