From ae84885cff2a7ca9cda86f7cd6649324ad689300 Mon Sep 17 00:00:00 2001 From: "G. Richardson" Date: Tue, 30 May 2017 11:09:39 +0200 Subject: [PATCH] =?utf8?q?Part=20Controller=20-=20mit=20n=C3=A4chster=20fr?= =?utf8?q?eier=20Nummer=20speichern?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Gibt man beim Anlegen eines neuen Artikels die Artikelnummer vor so wird beim Speichern eine Warnung angezeigt und der Speichervorgang abgebrochen. Lässt man die Artikelnummer frei und die nächste Artikelnummer (laut defaults articlenumber, servicenumber, ...) ist schon vergeben, so wird die nächste freie Artikelnummer genommen. Die Prüfung, ob die nächste Artikelnummer bereits vergeben ist, wurde daher entfernt. --- SL/Controller/Part.pm | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/SL/Controller/Part.pm b/SL/Controller/Part.pm index ee56b7a01..6477a902a 100644 --- a/SL/Controller/Part.pm +++ b/SL/Controller/Part.pm @@ -94,8 +94,11 @@ sub action_save { return $self->js->error(t8('The document has been changed by another user. Please reopen it in another window and copy the changes to the new window'))->render; } - if ( $is_new and !$::form->{part}{partnumber} ) { - $self->check_next_transnumber_is_free or return $self->js->error(t8('The next partnumber in the number range already exists!'))->render; + if ( $is_new + && $::form->{part}{partnumber} + && SL::DB::Manager::Part->find_by(partnumber => $::form->{part}{partnumber}) + ) { + return $self->js->error(t8('The partnumber is already being used'))->render; } $self->parse_form; @@ -1037,17 +1040,6 @@ sub form_check_partnumber_is_unique { } # general checking functions -sub check_next_transnumber_is_free { - my ($self) = @_; - - my ($next_transnumber, $count); - $self->part->db->with_transaction(sub { - $next_transnumber = $self->part->get_next_trans_number; - $count = SL::DB::Manager::Part->get_all_count(where => [ partnumber => $next_transnumber ]); - return 1; - }) or die $@; - $count ? return 0 : return 1; -} sub check_part_id { die t8("Can't load item without a valid part.id") . "\n" unless $::form->{part}{id}; -- 2.20.1