Revision 092a8193
Von Tamino Steinert vor 5 Tagen hinzugefügt
SL/DB/MetaSetup/Part.pm | ||
---|---|---|
53 | 53 |
|
54 | 54 |
__PACKAGE__->meta->primary_key_columns([ 'id' ]); |
55 | 55 |
|
56 |
__PACKAGE__->meta->unique_keys([ 'partnumber' ]); |
|
56 |
__PACKAGE__->meta->unique_keys( |
|
57 |
[ 'ean' ], |
|
58 |
[ 'partnumber' ], |
|
59 |
); |
|
57 | 60 |
|
58 | 61 |
__PACKAGE__->meta->allow_inline_column_values(1); |
59 | 62 |
|
SL/DB/Part.pm | ||
---|---|---|
136 | 136 |
__PACKAGE__->attr_sorted('businessmodels'); |
137 | 137 |
|
138 | 138 |
__PACKAGE__->before_save('_before_save_set_partnumber'); |
139 |
__PACKAGE__->before_save('_before_save_remove_empty_ean'); |
|
139 | 140 |
__PACKAGE__->before_save('_before_save_set_assembly_weight'); |
140 | 141 |
__PACKAGE__->before_save('_before_check_variant_property_values'); |
141 | 142 |
|
... | ... | |
146 | 147 |
return 1; |
147 | 148 |
} |
148 | 149 |
|
150 |
sub _before_save_remove_empty_ean { |
|
151 |
my ($self) = @_; |
|
152 |
|
|
153 |
$self->ean(undef) if defined $self->ean && $self->ean eq ''; |
|
154 |
return 1; |
|
155 |
} |
|
156 |
|
|
157 |
|
|
149 | 158 |
sub _before_save_set_assembly_weight { |
150 | 159 |
my ($self) = @_; |
151 | 160 |
|
... | ... | |
216 | 225 |
unless ( $self->id ) { |
217 | 226 |
push @errors, $::locale->text('The partnumber already exists.') if SL::DB::Manager::Part->get_all_count(where => [ partnumber => $self->partnumber ]); |
218 | 227 |
} |
228 |
push @errors, $::locale->text('The ean already exists.') if $self->ean ne '' && SL::DB::Manager::Part->get_all_count( |
|
229 |
where => [ |
|
230 |
ean => $self->ean, |
|
231 |
'!id' => $self->id, |
|
232 |
] |
|
233 |
); |
|
219 | 234 |
|
220 | 235 |
if ($self->is_assortment && $self->orphaned && scalar @{$self->assortment_items} == 0) { |
221 | 236 |
# when assortment isn't orphaned form doesn't contain any items |
locale/de/all | ||
---|---|---|
4178 | 4178 |
'The document has been printed.' => 'Das Dokument wurde gedruckt.', |
4179 | 4179 |
'The documents have been sent to the printer \'#1\'.' => 'Die Dokumente sind zum Drucker \'#1\' geschickt', |
4180 | 4180 |
'The dunnings have been printed.' => 'Die Mahnung(en) wurden gedruckt.', |
4181 |
'The ean already exists.' => 'Diese EAN existiert bereits', |
|
4181 | 4182 |
'The email entry for #1 looks invalid' => 'Die eingetragene E-Mail-Adresse für #1 sieht ungültig aus.', |
4182 | 4183 |
'The email has been sent.' => 'Die E-Mail wurde verschickt.', |
4183 | 4184 |
'The email was not sent due to the following error: #1.' => 'Die E-Mail wurde aufgrund des folgenden Fehlers nicht verschickt: #1', |
locale/en/all | ||
---|---|---|
4176 | 4176 |
'The document has been printed.' => '', |
4177 | 4177 |
'The documents have been sent to the printer \'#1\'.' => '', |
4178 | 4178 |
'The dunnings have been printed.' => '', |
4179 |
'The ean already exists.' => '', |
|
4179 | 4180 |
'The email entry for #1 looks invalid' => '', |
4180 | 4181 |
'The email has been sent.' => '', |
4181 | 4182 |
'The email was not sent due to the following error: #1.' => '', |
sql/Pg-upgrade2/parts_ean_unique.sql | ||
---|---|---|
1 |
-- @tag: parts_ean_unique |
|
2 |
-- @description: EAN in Artikel eindeutig machen |
|
3 |
-- @depends: release_3_8_0 |
|
4 |
-- @ignore: 0 |
|
5 |
|
|
6 |
UPDATE parts SET ean = null where ean = ''; |
|
7 |
ALTER TABLE parts ADD CONSTRAINT parts_ean_unique UNIQUE(ean); |
Auch abrufbar als: Unified diff
S:D:Part: EAN eindeutig machen