# and remember for the rest of the function
my $is_collective_order = scalar @ids;
- $form->{useasnew} = !!$is_collective_order;
+
+ # If collective order was created from exactly 1 order, we assume the same
+ # behaviour as a "save as new" from within an order is actually desired, i.e.
+ # the original order isn't part of a workflow where we want to remember
+ # record_links, but simply a quick way of generating a new order from an old
+ # one without having to enter everything again.
+ # Setting useasnew will prevent the creation of record_links for the items
+ # when saving the new order.
+ # This form variable is probably not necessary, could just set saveasnew instead
+ $form->{useasnew} = 1 if $is_collective_order == 1;
if (!$form->{id}) {
my $extra_days = $form->{type} eq 'sales_quotation' ? $::instance_conf->get_reqdate_interval : 1;
}
# delete orderitems_id in collective orders, so that they get cloned no matter what
+ # is this correct? or is the following meant?
+ # remember orderitems_ids in converted_from_orderitems_ids, so that they may be linked
$ref->{converted_from_orderitems_id} = delete $ref->{orderitems_id} if $is_collective_order;
# get tax rates and description