WebshopApi: falsche sql update Abhängigkeit
[kivitendo-erp.git] / SL / DB / PartsGroup.pm
1 # This file has been auto-generated only because it didn't exist.
2 # Feel free to modify it at will; it will not be overwritten automatically.
3
4 package SL::DB::PartsGroup;
5
6 use strict;
7
8 use SL::DB::MetaSetup::PartsGroup;
9 use SL::DB::Manager::PartsGroup;
10 use SL::DB::Helper::ActsAsList;
11
12 __PACKAGE__->meta->add_relationship(
13   custom_variable_configs => {
14     type                  => 'many to many',
15     map_class             => 'SL::DB::CustomVariableConfigPartsgroup',
16   },
17 );
18
19 __PACKAGE__->meta->initialize;
20
21 sub displayable_name {
22   my $self = shift;
23
24   return join ' ', grep $_, $self->id, $self->partsgroup;
25 }
26
27 sub validate {
28   my ($self) = @_;
29   require SL::DB::Customer;
30
31   my @errors;
32
33   push @errors, $::locale->text('The description is missing.') if $self->id and !$self->partsgroup;
34
35   return @errors;
36 }
37
38 sub orphaned {
39   my ($self) = @_;
40   die 'not an accessor' if @_ > 1;
41
42   return 1 unless $self->id;
43
44   my @relations = qw(
45     SL::DB::Part
46     SL::DB::CustomVariableConfigPartsgroup
47   );
48
49   for my $class (@relations) {
50     eval "require $class";
51     return 0 if $class->_get_manager_class->get_all_count(query => [ partsgroup_id => $self->id ]);
52   }
53
54   return 1;
55 }
56
57 1;