X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/kivitendo-erp.git/blobdiff_plain/179e3c4c9270c013ad411cae843fe842a1af3ec8..503fabbf4b2c77b2aab2dc1940f1eec0842cd490:/SL/DB/Part.pm diff --git a/SL/DB/Part.pm b/SL/DB/Part.pm index df0169d9c..c2cb641ae 100644 --- a/SL/DB/Part.pm +++ b/SL/DB/Part.pm @@ -165,6 +165,24 @@ sub last_modification { return $self->mtime // $self->itime; }; +sub used_in_record { + my ($self) = @_; + die 'not an accessor' if @_ > 1; + + return 1 unless $self->id; + + my @relations = qw( + SL::DB::InvoiceItem + SL::DB::OrderItem + SL::DB::DeliveryOrderItem + ); + + for my $class (@relations) { + eval "require $class"; + return 1 if $class->_get_manager_class->get_all_count(query => [ parts_id => $self->id ]); + } + return 0; +} sub orphaned { my ($self) = @_; die 'not an accessor' if @_ > 1; @@ -522,6 +540,10 @@ fields belonging to the tax zone given by C<$params{taxzone}>. The information retrieved by the function is cached. +=item C + +Checks if this article has been used in orders, invoices or delivery orders. + =item C Checks if this article is used in orders, invoices, delivery orders or