]> wagnertech.de Git - mfinanz.git/blobdiff - SL/OE.pm
Einkauf/Verkauf: Bemerkungsfeld mit HTML-Editor ausgestattet
[mfinanz.git] / SL / OE.pm
index c2cde7306823c188f27f74b734360677d0879d4f..061cd27a0b0fbc2d5007b6f639ea6b2a534415a7 100644 (file)
--- a/SL/OE.pm
+++ b/SL/OE.pm
@@ -571,7 +571,7 @@ SQL
 
       # link previous items with orderitems
       foreach (qw(orderitems invoice)) {
-        if (!$form->{saveasnew} && $form->{"converted_from_${_}_id_$i"}) {
+        if (!$form->{saveasnew} && !$form->{useasnew} && $form->{"converted_from_${_}_id_$i"}) {
           RecordLinks->create_links('dbh'        => $dbh,
                                     'mode'       => 'ids',
                                     'from_table' => $_,
@@ -634,7 +634,7 @@ SQL
              conv_i($form->{vendor_id}), conv_i($form->{customer_id}),
              $amount, $netamount, conv_date($reqdate),
              $form->{taxincluded} ? 't' : 'f', $form->{shippingpoint},
-             $form->{shipvia}, $form->{notes}, $form->{intnotes},
+             $form->{shipvia}, $restricter->process($form->{notes}), $form->{intnotes},
              $form->{currency}, $form->{closed} ? 't' : 'f',
              $form->{delivered} ? "t" : "f", $form->{proforma} ? 't' : 'f',
              $quotation, conv_i($form->{department_id}),
@@ -674,7 +674,7 @@ SQL
   delete $form->{convert_from_oe_ids};
   @{ $form->{convert_from_oe_ids} }      =  @convert_from_oe_ids;
   foreach (qw(ar oe)) {
-    if ($form->{"convert_from_${_}_ids"}) {
+    if (!$form->{useasnew} && $form->{"convert_from_${_}_ids"}) {
       RecordLinks->create_links('dbh'        => $dbh,
                                 'mode'       => 'ids',
                                 'from_table' => $_,
@@ -836,10 +836,12 @@ sub retrieve {
   if ($form->{"rowcount"} and $#ids == 0) {
     $form->{"id"} = $ids[0];
     undef @ids;
+    delete $form->{convert_from_oe_ids};
   }
 
   # and remember for the rest of the function
   my $is_collective_order = scalar @ids;
+  $form->{useasnew} = !!$is_collective_order;
 
   if (!$form->{id}) {
     my $extra_days   = $form->{type} eq 'sales_quotation' ? $::instance_conf->get_reqdate_interval : 1;
@@ -1044,7 +1046,7 @@ sub retrieve {
       }
 
       # delete orderitems_id in collective orders, so that they get cloned no matter what
-      delete $ref->{orderitems_id} if $is_collective_order;
+      $ref->{converted_from_orderitems_id} = delete $ref->{orderitems_id} if $is_collective_order;
 
       # get tax rates and description
       my $accno_id = ($form->{vc} eq "customer") ? $ref->{income_accno} : $ref->{expense_accno};