From db62bb400ec44815daf398a6a0eb5b5b6c9eb297 Mon Sep 17 00:00:00 2001
From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= <bernd@kivitendo-premium.de>
Date: Fri, 23 Nov 2018 17:25:50 +0100
Subject: [PATCH] Part-Controller: Normalisieren nach Parsen der Form und nicht
 als run_before
MIME-Version: 1.0
Content-Type: text/plain; charset=utf8
Content-Transfer-Encoding: 8bit

Das Problem enstand durch commit 2e97532c88dacf9523576df4028b6f7df5967ea8
"Fixt #349 (Normalisierung Artikel) - normalize_text_blocks nach Part-Controller
migriert"

normalize_text_blocks greift auf $self->part zu, welches beim Neuanlegen
noch nicht existiert, wenn normalize_text_blocks als aller erstes durch
run_before aufgerufen wird. Danach wurde init_part aufgerufen, welches
aber bei einem neue Artikel den part_type braucht, um part zu erzeugen.
Das ist aber nicht nötig, da das part in den action_add_xxx-Methoden
später erzeugt wird.
Ausserdem muss normalize_text_blocks z.B. auch nicht bei den Picker-Actions
aufgerufen werden.

Also normalize_text_blocks nur nach dem Parsen der Form aufrufen.

Fixt #361
---
 SL/Controller/Part.pm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/SL/Controller/Part.pm b/SL/Controller/Part.pm
index 31c670abb..e427cab4a 100644
--- a/SL/Controller/Part.pm
+++ b/SL/Controller/Part.pm
@@ -42,8 +42,6 @@ __PACKAGE__->run_before(sub { $::auth->assert('part_service_assembly_edit') },
 
 __PACKAGE__->run_before('check_part_id', only   => [ qw(edit delete) ]);
 
-__PACKAGE__->run_before('normalize_text_blocks');
-
 # actions for editing parts
 #
 sub action_add_part {
@@ -735,6 +733,8 @@ sub parse_form {
   $self->part->assign_attributes(%{ $params});
   $self->part->bin_id(undef) unless $self->part->warehouse_id;
 
+  $self->normalize_text_blocks;
+
   # Only reset items ([]) and rewrite from form if $::form->{assortment_items} isn't empty. This
   # will be the case for used assortments when saving, or when a used assortment
   # is "used as new"
-- 
2.20.1