Fixed partkeepr import with databases that do not feature custom states

This commit is contained in:
Jan Böhmer 2025-12-07 20:21:19 +01:00
parent b1bf70c531
commit c60b406157
2 changed files with 5 additions and 2 deletions

View file

@ -152,7 +152,7 @@ class PKDatastructureImporter
public function importPartCustomStates(array $data): int
{
if (!isset($data['partcustomstate'])) {
throw new \RuntimeException('$data must contain a "partcustomstate" key!');
return 0; //Not all PartKeepr installations have custom states
}
$partCustomStateData = $data['partcustomstate'];

View file

@ -91,7 +91,10 @@ class PKPartImporter
$this->setAssociationField($entity, 'partUnit', MeasurementUnit::class, $part['partUnit_id']);
}
$this->setAssociationField($entity, 'partCustomState', MeasurementUnit::class, $part['partCustomState_id']);
if (isset($part['partCustomState_id'])) {
$this->setAssociationField($entity, 'partCustomState', MeasurementUnit::class,
$part['partCustomState_id']);
}
//Create a part lot to store the stock level and location
$lot = new PartLot();