$query->one() can return null when the record is deleted, sent to 1C,
or the user has no store access. Without the check, line 1076 crashes
with "Call to a member function getRelation() on null".
Now throws NotFoundHttpException (404) as documented in the PHPDoc.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
$model = $query->one();
+ if ($model === null) {
+ throw new NotFoundHttpException('Списание не найдено или недоступно.');
+ }
$modelWriteOffsProductsErps = ($model->getRelation('writeOffsProductsErps', false));
$model->writeOffsProductsErps = ArrayHelper::getValue($model->getRelatedRecords(), 'writeOffsProductsErps');