# Unable to generate document. Only versioned orders can be used for document generation

**URL:** https://forum.shopware.com/t/unable-to-generate-document-only-versioned-orders-can-be-used-for-document-generation/87198
**Category:** Shopware 6 (English)
**Tags:** general, administration
**Created:** [28. April 2021 um 07:42 UTC](https://forum.shopware.com/t/unable-to-generate-document-only-versioned-orders-can-be-used-for-document-generation/87198 "2021-04-28T07:42:34Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![abinjohnedamana](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/abinjohnedamana/32/17378_2.png) [@abinjohnedamana](https://forum.shopware.com/u/abinjohnedamana)
#### Post date: [28. April 2021 um 07:42 UTC](https://forum.shopware.com/t/unable-to-generate-document-only-versioned-orders-can-be-used-for-document-generation/87198/1 "2021-04-28T07:42:34Z")

</div>

Hi

When I am trying to download a „Cancellation bill“ from admin order details I am getting the following error and the file is not downloading

`{"errors":[{"status":"400","code":"DOCUMENT__GENERATION_ERROR","title":"Bad Request","detail":"Unable to generate document. Only versioned orders can be used for document generation.","meta":{"parameters":[]}}]}`

What does that mean? How to download the file?

---

<div class="post-metadata">

### Author: ![abinjohnedamana](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/abinjohnedamana/32/17378_2.png) [@abinjohnedamana](https://forum.shopware.com/u/abinjohnedamana)
#### Post date: [28. April 2021 um 08:07 UTC](https://forum.shopware.com/t/unable-to-generate-document-only-versioned-orders-can-be-used-for-document-generation/87198/2 "2021-04-28T08:07:27Z")

</div>

It is a Shopware bug and the fix is available only in 6.4.0.0 which we cannot use in production.

> **[Shopware Issuetracker](https://issues.shopware.com/issues/NEXT-13653)**

So please edit the core file vendor/shopware/core/Checkout/Document/DocumentService.php

Replace the file function validateVersion with the following content

```
private function validateVersion(DocumentEntity $document, Context $context): void
{
    if ($document->getOrderVersionId() === Defaults::LIVE_VERSION) {
        // Only versioned orders can be used for document generation.
        $orderVersionId = $this->orderRepository->createVersion($document->getOrderId(), $context);
        $document->setOrderVersionId($orderVersionId);
        $this->documentRepository->update(
            [
                [
                    'id' => $document->getId(),
                    'orderVersionId' => $orderVersionId,
                ],
            ],
            $context
        );
    }
}

and also replace its function call with $this->validateVersion($document, $context);

```

There is no other solution for live site users. This is not good at all!
