Revision 47dc096c
Von Sven Schöling vor fast 2 Jahren hinzugefügt
SL/Controller/DeliveryOrder.pm | ||
---|---|---|
32 | 32 |
use SL::DB::TransferType; |
33 | 33 |
use SL::DB::ValidityToken; |
34 | 34 |
use SL::DB::Warehouse; |
35 |
use SL::DB::Helper::RecordLink qw(set_record_link_conversions); |
|
35 | 36 |
use SL::Model::Record; |
36 | 37 |
|
37 | 38 |
use SL::Helper::CreatePDF qw(:all); |
... | ... | |
1664 | 1665 |
# link records |
1665 | 1666 |
if ($::form->{converted_from_oe_id}) { |
1666 | 1667 |
my @converted_from_oe_ids = split ' ', $::form->{converted_from_oe_id}; |
1667 |
foreach my $converted_from_oe_id (@converted_from_oe_ids) { |
|
1668 |
my $src = SL::DB::Order->new(id => $converted_from_oe_id)->load; |
|
1669 |
$src->update_attributes(closed => 1) if $src->type =~ /_quotation$/ && $self->order->is_type(PURCHASE_DELIVERY_ORDER_TYPE); |
|
1670 |
$src->link_to_record($self->order); |
|
1671 |
} |
|
1672 |
if (scalar @{ $::form->{converted_from_orderitems_ids} || [] }) { |
|
1673 |
my $idx = 0; |
|
1674 |
foreach (@{ $self->order->items_sorted }) { |
|
1675 |
my $from_id = $::form->{converted_from_orderitems_ids}->[$idx]; |
|
1676 |
next if !$from_id; |
|
1677 |
SL::DB::RecordLink->new(from_table => 'orderitems', |
|
1678 |
from_id => $from_id, |
|
1679 |
to_table => 'orderitems', |
|
1680 |
to_id => $_->id |
|
1681 |
)->save; |
|
1682 |
$idx++; |
|
1683 |
} |
|
1684 |
} |
|
1668 |
set_record_link_conversions( |
|
1669 |
$self->order, |
|
1670 |
'SL::DB::Order' => \@converted_from_oe_ids, |
|
1671 |
'SL::DB::OrderItem' => $::form->{converted_from_orderitems_ids}, |
|
1672 |
); |
|
1685 | 1673 |
} |
1686 | 1674 |
if ($::form->{converted_from_reclamation_id}) { |
1687 | 1675 |
my @converted_from_reclamation_ids = split ' ', $::form->{converted_from_reclamation_id}; |
1688 |
foreach my $converted_from_reclamation_id (@converted_from_reclamation_ids) { |
|
1689 |
my $src = SL::DB::Reclamation->new(id => $converted_from_reclamation_id)->load; |
|
1690 |
if(!$::instance_conf->get_shipped_qty_require_stock_out || $self->order->delivered) { |
|
1691 |
$src->update_attributes(delivered => 1); |
|
1692 |
} |
|
1693 |
$src->link_to_record($self->order); |
|
1694 |
} |
|
1695 |
if (scalar @{ $::form->{converted_from_reclamation_items_ids} || [] }) { |
|
1696 |
my $idx = 0; |
|
1697 |
foreach (@{ $self->order->items_sorted }) { |
|
1698 |
my $from_id = $::form->{converted_from_reclamation_items_ids}->[$idx]; |
|
1699 |
next if !$from_id; |
|
1700 |
SL::DB::RecordLink->new(from_table => 'reclamation_items', |
|
1701 |
from_id => $from_id, |
|
1702 |
to_table => 'orderitems', |
|
1703 |
to_id => $_->id |
|
1704 |
)->save; |
|
1705 |
$idx++; |
|
1706 |
} |
|
1707 |
} |
|
1676 |
set_record_link_conversions( |
|
1677 |
$self->order, |
|
1678 |
'SL::DB::Reclamation' => \@converted_from_reclamation_ids, |
|
1679 |
'SL::DB::ReclamationItem' => $::form->{converted_from_reclamation_items_ids}, |
|
1680 |
); |
|
1708 | 1681 |
} |
1709 | 1682 |
|
1710 | 1683 |
$self->save_history('SAVED'); |
SL/Controller/Order.pm | ||
---|---|---|
32 | 32 |
use SL::DB::Shipto; |
33 | 33 |
use SL::DB::Translation; |
34 | 34 |
use SL::DB::ValidityToken; |
35 |
use SL::DB::Helper::RecordLink qw(set_record_link_conversions); |
|
35 | 36 |
use SL::Model::Record; |
36 | 37 |
|
37 | 38 |
use SL::Helper::CreatePDF qw(:all); |
... | ... | |
2156 | 2157 |
# link records |
2157 | 2158 |
if ($::form->{converted_from_oe_id}) { |
2158 | 2159 |
my @converted_from_oe_ids = split ' ', $::form->{converted_from_oe_id}; |
2159 |
|
|
2160 |
foreach my $converted_from_oe_id (@converted_from_oe_ids) { |
|
2161 |
my $src = SL::DB::Order->new(id => $converted_from_oe_id)->load; |
|
2162 |
$src->update_attributes(closed => 1) if $src->type =~ /_quotation$/; |
|
2163 |
$src->link_to_record($self->order); |
|
2164 |
} |
|
2165 |
if (scalar @{ $::form->{converted_from_orderitems_ids} || [] }) { |
|
2166 |
my $idx = 0; |
|
2167 |
foreach (@{ $self->order->items_sorted }) { |
|
2168 |
my $from_id = $::form->{converted_from_orderitems_ids}->[$idx]; |
|
2169 |
next if !$from_id; |
|
2170 |
SL::DB::RecordLink->new(from_table => 'orderitems', |
|
2171 |
from_id => $from_id, |
|
2172 |
to_table => 'orderitems', |
|
2173 |
to_id => $_->id |
|
2174 |
)->save; |
|
2175 |
$idx++; |
|
2176 |
} |
|
2177 |
} |
|
2160 |
set_record_link_conversions( |
|
2161 |
$self->order, |
|
2162 |
'SL::DB::Order' => \@converted_from_oe_ids, |
|
2163 |
'SL::DB::OrderItem' => $::form->{converted_from_orderitems_ids}, |
|
2164 |
); |
|
2178 | 2165 |
|
2179 | 2166 |
$self->link_requirement_specs_linking_to_created_from_objects(@converted_from_oe_ids); |
2180 | 2167 |
} |
2181 | 2168 |
if ($::form->{converted_from_reclamation_id}) { |
2182 | 2169 |
my @converted_from_reclamation_ids = split ' ', $::form->{converted_from_reclamation_id}; |
2183 |
|
|
2184 |
foreach my $converted_from_reclamation_id (@converted_from_reclamation_ids) { |
|
2185 |
my $src = SL::DB::Reclamation->new(id => $converted_from_reclamation_id)->load; |
|
2186 |
$src->link_to_record($self->order); |
|
2187 |
} |
|
2188 |
if (scalar @{ $::form->{converted_from_reclamation_items_ids} || [] }) { |
|
2189 |
my $idx = 0; |
|
2190 |
foreach (@{ $self->order->items_sorted }) { |
|
2191 |
my $from_id = $::form->{converted_from_reclamation_items_ids}->[$idx]; |
|
2192 |
next if !$from_id; |
|
2193 |
SL::DB::RecordLink->new(from_table => 'reclamation_items', |
|
2194 |
from_id => $from_id, |
|
2195 |
to_table => 'orderitems', |
|
2196 |
to_id => $_->id |
|
2197 |
)->save; |
|
2198 |
$idx++; |
|
2199 |
} |
|
2200 |
} |
|
2170 |
set_record_links_conversions( |
|
2171 |
$self->order, |
|
2172 |
'SL::DB::Reclamation' => \@converted_from_reclamation_ids, |
|
2173 |
'SL::DB::ReclamationItem' => $::form->{converted_from_reclamation_items_ids}, |
|
2174 |
); |
|
2201 | 2175 |
} |
2202 | 2176 |
|
2203 | 2177 |
$self->set_project_in_linked_requirement_specs if $self->order->globalproject_id; |
SL/Controller/Reclamation.pm | ||
---|---|---|
26 | 26 |
use SL::DB::Shipto; |
27 | 27 |
use SL::DB::Translation; |
28 | 28 |
use SL::DB::ValidityToken; |
29 |
use SL::DB::Helper::RecordLink qw(RECORD_ID RECORD_TYPE_REF RECORD_ITEM_ID RECORD_ITEM_TYPE_REF); |
|
29 | 30 |
|
30 | 31 |
use SL::Helper::CreatePDF qw(:all); |
31 | 32 |
use SL::Helper::PrintOptions; |
... | ... | |
1707 | 1708 |
|
1708 | 1709 |
my $reclamation = $self->reclamation; |
1709 | 1710 |
|
1710 |
$reclamation->{converted_from_record_id} = delete $::form->{converted_from_record_id};
|
|
1711 |
$reclamation->{converted_from_record_type_ref} = delete $::form->{converted_from_record_type_ref};
|
|
1711 |
$reclamation->{RECORD_ID()} = delete $::form->{converted_from_record_id};
|
|
1712 |
$reclamation->{RECORD_TYPE_REF()} = delete $::form->{converted_from_record_type_ref};
|
|
1712 | 1713 |
|
1713 | 1714 |
my $from_record_item_ids = delete $::form->{converted_from_record_item_ids} ; |
1714 | 1715 |
my $from_record_item_type_refs = delete $::form->{converted_from_record_item_type_refs} ; |
... | ... | |
1716 | 1717 |
if (scalar @{ $from_record_item_ids || [] }) { |
1717 | 1718 |
for my $idx (0 .. $#{ $reclamation->items_sorted }) { |
1718 | 1719 |
my $reclamation_item = $reclamation->items_sorted->[$idx]; |
1719 |
$reclamation_item->{converted_from_record_item_id} = $from_record_item_ids->[$idx];
|
|
1720 |
$reclamation_item->{converted_from_record_item_type_ref} = $from_record_item_type_refs->[$idx];
|
|
1720 |
$reclamation_item->{RECORD_ITEM_ID()} = $from_record_item_ids->[$idx];
|
|
1721 |
$reclamation_item->{RECORD_ITEM_TYPE_REF()} = $from_record_item_type_refs->[$idx];
|
|
1721 | 1722 |
} |
1722 | 1723 |
} |
1723 | 1724 |
} |
Auch abrufbar als: Unified diff
RecordLink: conversions nicht mehr manuell in Controllern machen
stattdessen per Helper setzen lassen