Revision bf78e242
Von Kivitendo Admin vor mehr als 7 Jahren hinzugefügt
SL/DB/Part.pm | ||
---|---|---|
165 | 165 |
return $self->mtime // $self->itime; |
166 | 166 |
}; |
167 | 167 |
|
168 |
sub used_in_record { |
|
169 |
my ($self) = @_; |
|
170 |
die 'not an accessor' if @_ > 1; |
|
171 |
|
|
172 |
return 1 unless $self->id; |
|
173 |
|
|
174 |
my @relations = qw( |
|
175 |
SL::DB::InvoiceItem |
|
176 |
SL::DB::OrderItem |
|
177 |
SL::DB::DeliveryOrderItem |
|
178 |
); |
|
179 |
|
|
180 |
for my $class (@relations) { |
|
181 |
eval "require $class"; |
|
182 |
return 1 if $class->_get_manager_class->get_all_count(query => [ parts_id => $self->id ]); |
|
183 |
} |
|
184 |
return 0; |
|
185 |
} |
|
168 | 186 |
sub orphaned { |
169 | 187 |
my ($self) = @_; |
170 | 188 |
die 'not an accessor' if @_ > 1; |
... | ... | |
522 | 540 |
|
523 | 541 |
The information retrieved by the function is cached. |
524 | 542 |
|
543 |
=item C<used_in_record> |
|
544 |
|
|
545 |
Checks if this article has been used in orders, invoices or delivery orders. |
|
546 |
|
|
525 | 547 |
=item C<orphaned> |
526 | 548 |
|
527 | 549 |
Checks if this article is used in orders, invoices, delivery orders or |
Auch abrufbar als: Unified diff
neue SL::DB::Part Methode used_in_record.
Die Prüfung auf orphaned ist viel strenger, und sollte für z.B. Löschen
verwendet werden, während used_in_record nur prüft, ob der Artikel in
Belegen vorkommt.