Revision cb2f7c5b
Von Bernd Bleßmann vor fast 2 Jahren hinzugefügt
SL/Model/Record.pm | ||
---|---|---|
8 | 8 |
use SL::DB::Order; |
9 | 9 |
use SL::DB::DeliveryOrder; |
10 | 10 |
use SL::DB::Reclamation; |
11 |
use SL::DB::RequirementSpecOrder; |
|
11 | 12 |
use SL::DB::History; |
12 | 13 |
use SL::DB::Invoice; |
13 | 14 |
use SL::DB::Status; |
... | ... | |
226 | 227 |
|
227 | 228 |
$record->save(cascade => 1); |
228 | 229 |
|
229 |
# # link records
|
|
230 |
# if (@converted_from_oe_ids) {
|
|
231 |
# $self->link_requirement_specs_linking_to_created_from_objects(@converted_from_oe_ids);
|
|
232 |
# }
|
|
230 |
# link records for requirement specs
|
|
231 |
if (my $converted_from_ids = $params{link_requirement_specs_linking_to_created_from_objects}) {
|
|
232 |
_link_requirement_specs_linking_to_created_from_objects($record, $converted_from_ids);
|
|
233 |
} |
|
233 | 234 |
|
234 |
# $self->set_project_in_linked_requirement_specs if $self->order->globalproject_id; |
|
235 |
if ($params{set_project_in_linked_requirement_specs}) { # flag? |
|
236 |
_set_project_in_linked_requirement_specs($record); |
|
237 |
} |
|
235 | 238 |
|
236 | 239 |
_save_history($record, 'SAVED', %{$params{history}}); |
237 | 240 |
|
... | ... | |
241 | 244 |
}); |
242 | 245 |
} |
243 | 246 |
|
247 |
# Todo: put this into SL::DB::Order? |
|
248 |
sub _link_requirement_specs_linking_to_created_from_objects { |
|
249 |
my ($record, $converted_from_oe_ids) = @_; |
|
250 |
|
|
251 |
return unless $converted_from_oe_ids; |
|
252 |
return unless @$converted_from_oe_ids; |
|
253 |
|
|
254 |
my $rs_orders = SL::DB::Manager::RequirementSpecOrder->get_all(where => [ order_id => $converted_from_oe_ids ]); |
|
255 |
foreach my $rs_order (@{ $rs_orders }) { |
|
256 |
SL::DB::RequirementSpecOrder->new( |
|
257 |
order_id => $record->id, |
|
258 |
requirement_spec_id => $rs_order->requirement_spec_id, |
|
259 |
version_id => $rs_order->version_id, |
|
260 |
)->save; |
|
261 |
} |
|
262 |
} |
|
263 |
|
|
264 |
sub _set_project_in_linked_requirement_specs { |
|
265 |
my ($record) = @_; |
|
266 |
|
|
267 |
return unlsess $record->globalproject_id; |
|
268 |
|
|
269 |
my $rs_orders = SL::DB::Manager::RequirementSpecOrder->get_all(where => [ order_id => $record->id ]); |
|
270 |
foreach my $rs_order (@{ $rs_orders }) { |
|
271 |
next if $rs_order->requirement_spec->project_id == $record->globalproject_id; |
|
272 |
|
|
273 |
$rs_order->requirement_spec->update_attributes(project_id => $record->globalproject_id); |
|
274 |
} |
|
275 |
} |
|
276 |
|
|
244 | 277 |
sub update_for_save_as_new { |
245 | 278 |
my ($class, $saved_record, $changed_record, %params) = @_; |
246 | 279 |
|
Auch abrufbar als: Unified diff
Model::Record->save: Pflichtenheft: Verknüpfungen und Projekt setzen können