- # Link this record to the records it was created from.
- if ($form->{convert_from_oe_ids}) {
- RecordLinks->create_links('dbh' => $dbh,
- 'mode' => 'ids',
- 'from_table' => 'oe',
- 'from_ids' => $form->{convert_from_oe_ids},
- 'to_table' => 'ap',
- 'to_id' => $form->{id},
+ # Link this record to the records it was created from order or invoice (storno)
+ foreach (qw(oe ap)) {
+ if ($form->{"convert_from_${_}_ids"}) {
+ RecordLinks->create_links('dbh' => $dbh,
+ 'mode' => 'ids',
+ 'from_table' => $_,
+ 'from_ids' => $form->{"convert_from_${_}_ids"},
+ 'to_table' => 'ap',
+ 'to_id' => $form->{id},