X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/kivitendo-erp.git/blobdiff_plain/7f5edaa695f8e23af197c4b82b66ca2e1bbfc35e..984f6322b98c8d0cd3ceb9f659ed6621d180e617:/SL/DB/Object.pm diff --git a/SL/DB/Object.pm b/SL/DB/Object.pm index c258761d1..f2f12c00d 100755 --- a/SL/DB/Object.pm +++ b/SL/DB/Object.pm @@ -22,6 +22,12 @@ my @rose_reserved_methods = qw( not_found save update import ); +my %db_to_presenter_mapping = ( + Customer => 'CustomerVendor', + PurchaseInvoice => 'Invoice', + Vendor => 'CustomerVendor', +); + sub new { my $class = shift; my $self = $class->SUPER::new(); @@ -240,16 +246,13 @@ sub clone_and_reset { } sub presenter { - my ($class_or_self) = @_; - - if (ref $class_or_self) { - my $class = ref $class_or_self; - $class =~ s{^SL::DB::}{SL::Presenter::}; - return SL::DB::Helper::Presenter->new($class, $class_or_self); - } else { - $class_or_self =~ s{^SL::DB::}{SL::Presenter::}; - return $class_or_self; - } + my ($self) = @_; + + my $class = ref $self; + $class =~ s{^SL::DB::}{}; + $class = "SL::Presenter::" . ($db_to_presenter_mapping{$class} // $class); + + return SL::DB::Helper::Presenter->new($class, $self); } sub as_debug_info {