Revision 4d173f1a
Added by Tamino Steinert about 1 month ago
SL/Controller/DeliveryOrder.pm | ||
---|---|---|
96 | 96 |
sub action_add { |
97 | 97 |
my ($self) = @_; |
98 | 98 |
|
99 |
$self->order(SL::Model::Record->update_after_new($self->order)); |
|
100 |
|
|
101 | 99 |
$self->pre_render(); |
102 | 100 |
|
103 | 101 |
if (!$::form->{form_validity_token}) { |
... | ... | |
149 | 147 |
|
150 | 148 |
my $delivery_order = SL::Model::Record->new_from_workflow($record, $self->type, %flags); |
151 | 149 |
$self->order($delivery_order); |
150 |
$self->reinit_after_new_order(); |
|
152 | 151 |
|
153 | 152 |
$self->action_add; |
154 | 153 |
} |
... | ... | |
942 | 941 |
sub action_return_from_create_part { |
943 | 942 |
my ($self) = @_; |
944 | 943 |
|
945 |
$self->{created_part} = |
|
946 |
SL::DB::Part->new(id => delete $::form->{new_parts_id})->load
|
|
947 |
if $::form->{new_parts_id};
|
|
944 |
$self->{created_part} = SL::DB::Part->new(
|
|
945 |
id => delete $::form->{new_parts_id}
|
|
946 |
)->load if $::form->{new_parts_id};
|
|
948 | 947 |
|
949 | 948 |
$::auth->restore_form_from_session(delete $::form->{previousform}); |
950 | 949 |
|
951 |
# set item ids to new fake id, to identify them as new items |
|
952 |
foreach my $item (@{$self->order->items_sorted}) { |
|
953 |
$item->{new_fake_id} = join('_', |
|
954 |
'new', |
|
955 |
Time::HiRes::gettimeofday(), |
|
956 |
int rand 1000000000000 |
|
957 |
); |
|
958 |
} |
|
959 |
|
|
960 |
$self->get_unalterable_data(); |
|
961 |
$self->pre_render(); |
|
950 |
$self->order($self->init_order); |
|
951 |
$self->reinit_after_new_order(); |
|
962 | 952 |
|
963 |
# trigger rendering values for second row/longdescription as hidden,
|
|
964 |
# because they are loaded only on demand. So we need to keep the values
|
|
965 |
# from the source.
|
|
966 |
$_->{render_second_row} = 1 for @{ $self->order->items_sorted };
|
|
967 |
$_->{render_longdescription} = 1 for @{ $self->order->items_sorted };
|
|
953 |
if ($self->order->id) {
|
|
954 |
$self->action_edit;
|
|
955 |
} else {
|
|
956 |
$self->action_add;
|
|
957 |
}
|
|
968 | 958 |
|
969 |
$self->render( |
|
970 |
'delivery_order/form', |
|
971 |
title => $self->get_title_for('edit'), |
|
972 |
%{$self->{template_args}} |
|
973 |
); |
|
974 | 959 |
} |
975 | 960 |
|
976 | 961 |
sub action_stock_in_out_dialog { |
... | ... | |
1608 | 1593 |
if ($::form->{id}) { |
1609 | 1594 |
$order = SL::DB::DeliveryOrder->new( |
1610 | 1595 |
id => $::form->{id} |
1611 |
)->load(with => [ 'orderitems', 'orderitems.part' ]); |
|
1596 |
)->load( |
|
1597 |
with => [ |
|
1598 |
'orderitems', |
|
1599 |
'orderitems.part', |
|
1600 |
] |
|
1601 |
); |
|
1612 | 1602 |
} else { |
1613 | 1603 |
$order = SL::DB::DeliveryOrder->new( |
1614 | 1604 |
orderitems => [], |
1615 | 1605 |
currency_id => $::instance_conf->get_currency_id(), |
1616 | 1606 |
record_type => $::form->{type} |
1617 | 1607 |
); |
1608 |
$order = SL::Model::Record->update_after_new($order); |
|
1618 | 1609 |
} |
1619 | 1610 |
|
1620 | 1611 |
my $cv_id_method = $order->type_data->properties('customervendor'). '_id'; |
... | ... | |
1857 | 1848 |
$self->order($delivery_order); |
1858 | 1849 |
$self->{converted_from_oe_id} = delete $::form->{id}; |
1859 | 1850 |
|
1860 |
# set item ids to new fake id, to identify them as new items |
|
1861 |
foreach my $item (@{$self->order->items_sorted}) { |
|
1862 |
$item->{new_fake_id} = join('_', |
|
1863 |
'new', |
|
1864 |
Time::HiRes::gettimeofday(), |
|
1865 |
int rand 1000000000000 |
|
1866 |
); |
|
1867 |
} |
|
1851 |
$self->reinit_after_new_order(); |
|
1852 |
|
|
1853 |
$self->render( |
|
1854 |
'delivery_order/form', |
|
1855 |
title => $self->get_title_for('edit'), |
|
1856 |
%{$self->{template_args}} |
|
1857 |
); |
|
1858 |
} |
|
1859 |
|
|
1860 |
sub reinit_after_new_order { |
|
1861 |
my ($self) = @_; |
|
1868 | 1862 |
|
1869 | 1863 |
# change form type |
1870 |
$::form->{type} = $destination_type;
|
|
1864 |
$::form->{type} = $self->order->type;
|
|
1871 | 1865 |
$self->type($self->init_type); |
1872 | 1866 |
$self->cv ($self->init_cv); |
1873 | 1867 |
$self->check_auth; |
1874 | 1868 |
|
1875 |
$self->get_unalterable_data(); |
|
1876 |
$self->pre_render(); |
|
1869 |
foreach my $item (@{$self->order->items_sorted}) { |
|
1870 |
# set item ids to new fake id, to identify them as new items |
|
1871 |
$item->{new_fake_id} = join('_', 'new', Time::HiRes::gettimeofday(), int rand 1000000000000); |
|
1877 | 1872 |
|
1878 |
# trigger rendering values for second row as hidden, because they |
|
1879 |
# are loaded only on demand. So we need to keep the values from the |
|
1880 |
# source. |
|
1881 |
$_->{render_second_row} = 1 for @{ $self->order->items_sorted }; |
|
1873 |
# trigger rendering values for second row as hidden, because they |
|
1874 |
# are loaded only on demand. So we need to keep the values from the |
|
1875 |
# source. |
|
1876 |
$item->{render_second_row} = 1; |
|
1877 |
} |
|
1882 | 1878 |
|
1883 |
$self->render( |
|
1884 |
'delivery_order/form', |
|
1885 |
title => $self->get_title_for('edit'), |
|
1886 |
%{$self->{template_args}} |
|
1887 |
); |
|
1879 |
$self->get_unalterable_data(); |
|
1888 | 1880 |
} |
1889 | 1881 |
|
1882 |
|
|
1890 | 1883 |
sub pre_render { |
1891 | 1884 |
my ($self) = @_; |
1892 | 1885 |
|
Also available in: Unified diff
FIX: S:C:DeliveryOrder: Daten über Workflows vollständig und korrekt laden