diff --git a/admin-dev/themes/default/template/controllers/orders/_documents.tpl b/admin-dev/themes/default/template/controllers/orders/_documents.tpl
index 95b0570c8..29bddbbfa 100644
--- a/admin-dev/themes/default/template/controllers/orders/_documents.tpl
+++ b/admin-dev/themes/default/template/controllers/orders/_documents.tpl
@@ -118,11 +118,13 @@
{/if}
{/if}
- {foreachelse}
+ {foreachelse}
{l s='No document is available'}
+ {if $invoice_management_active}
{l s='Generate invoice'}
+ {/if}
|
{/foreach}
diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php
index 20e9400e3..4110ed96f 100755
--- a/controllers/admin/AdminOrdersController.php
+++ b/controllers/admin/AdminOrdersController.php
@@ -825,7 +825,9 @@ class AdminOrdersControllerCore extends AdminController
}
elseif (Tools::isSubmit('submitGenerateInvoice') && isset($order))
{
- if ($order->hasInvoice())
+ if (!Configuration::get('PS_INVOICE'))
+ $this->errors[] = Tools::displayError('Invoice management has been disabled');
+ elseif ($order->hasInvoice())
$this->errors[] = Tools::displayError('This order already has an invoice');
else
{
@@ -1179,6 +1181,7 @@ class AdminOrdersControllerCore extends AdminController
'invoices_collection' => $order->getInvoicesCollection(),
'not_paid_invoices_collection' => $order->getNotPaidInvoicesCollection(),
'payment_methods' => $payment_methods,
+ 'invoice_management_active' => Configuration::get('PS_INVOICE')
);
return parent::renderView();