Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 1fdc73d9

Von Tamino Steinert vor fast 2 Jahren hinzugefügt

  • ID 1fdc73d9cb94a3a6cb53910a9dd4c81573b75b71
  • Vorgänger 7282e848
  • Nachfolger b3590a23

Reclamation: don't save order after converting

Unterschiede anzeigen:

SL/Controller/Order.pm
97 97

  
98 98
  require SL::DB::Reclamation;
99 99
  my $reclamation = SL::DB::Reclamation->new(id => $::form->{from_id})->load;
100
  my $order = $reclamation->convert_to_order();
100
  my %params;
101
  $params{destination_type} = $reclamation->is_sales ? 'sales_order'
102
                                              : 'purchase_order';
103
  my $order = SL::DB::Order->new_from($reclamation, %params);
104
  $self->{converted_from_reclamation_id} = $::form->{from_id};
101 105

  
102 106
  $self->order($order);
103 107

  
......
1609 1613
  $self->js
1610 1614
    ->val('#id', $self->order->id)
1611 1615
    ->val('#converted_from_oe_id', '')
1616
    ->val('#converted_from_reclamation_id', '')
1612 1617
    ->val('#order_' . $self->nr_key(), $self->order->number);
1613 1618

  
1614 1619
  my $idx = 0;
......
1623 1628
    $idx++;
1624 1629
  }
1625 1630
  $self->js->val('[name="converted_from_orderitems_ids[+]"]', '');
1631
  $self->js->val('[name="converted_from_reclamation_items_ids[+]"]', '');
1626 1632
}
1627 1633

  
1628 1634
#
......
2157 2163

  
2158 2164
      $self->link_requirement_specs_linking_to_created_from_objects(@converted_from_oe_ids);
2159 2165
    }
2166
    if ($::form->{converted_from_reclamation_id}) {
2167
      my @converted_from_reclamation_ids = split ' ', $::form->{converted_from_reclamation_id};
2168

  
2169
      foreach my $converted_from_reclamation_id (@converted_from_reclamation_ids) {
2170
        my $src = SL::DB::Reclamation->new(id => $converted_from_reclamation_id)->load;
2171
        $src->link_to_record($self->order);
2172
      }
2173
      if (scalar @{ $::form->{converted_from_reclamation_items_ids} || [] }) {
2174
        my $idx = 0;
2175
        foreach (@{ $self->order->items_sorted }) {
2176
          my $from_id = $::form->{converted_from_reclamation_items_ids}->[$idx];
2177
          next if !$from_id;
2178
          SL::DB::RecordLink->new(from_table => 'reclamation_items',
2179
                                  from_id    => $from_id,
2180
                                  to_table   => 'orderitems',
2181
                                  to_id      => $_->id
2182
          )->save;
2183
          $idx++;
2184
        }
2185
      }
2186
    }
2160 2187

  
2161 2188
    $self->set_project_in_linked_requirement_specs if $self->order->globalproject_id;
2162 2189

  
templates/webpages/order/form.html
22 22
  [% L.hidden_tag('type',                 FORM.type) %]
23 23
  [% L.hidden_tag('id',                   SELF.order.id) %]
24 24
  [% L.hidden_tag('converted_from_oe_id', SELF.converted_from_oe_id) %]
25
  [% L.hidden_tag('converted_from_reclamation_id', SELF.converted_from_reclamation_id) %]
25 26

  
26 27
  [%- INCLUDE 'common/flash.html' %]
27 28

  
templates/webpages/order/tabs/_row.html
16 16
      [%- END %]
17 17
      [% L.hidden_tag("orderitem_ids[+]", ID) %]
18 18
      [% L.hidden_tag("converted_from_orderitems_ids[+]", ITEM.converted_from_orderitems_id) %]
19
      [% L.hidden_tag("converted_from_reclamation_items_ids[+]", ITEM.converted_from_reclamation_items_id) %]
19 20
      [% L.hidden_tag("order.orderitems[+].id", ITEM.id, id='item_' _ ID) %]
20 21
      [% L.hidden_tag("order.orderitems[].parts_id", ITEM.parts_id) %]
21 22
    </td>

Auch abrufbar als: Unified diff