handle the case that the Invoice model is missing
authorPhilipp Schüle <p.schuele@metaways.de>
Thu, 30 Jul 2015 09:43:18 +0000 (11:43 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Thu, 30 Jul 2015 11:06:24 +0000 (13:06 +0200)
... maybe the server did not deliver the model data in the registry

and show a log message, if feature is disabled.

Change-Id: Ia20171a1fbdd1aab2604cc07dfa2756812e1a753
Reviewed-on: http://gerrit.tine20.com/customers/2080
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tine20/Sales/Frontend/Json.php
tine20/Timetracker/js/TimeaccountEditDialog.js
tine20/Timetracker/js/TimesheetEditDialog.js

index 4648a73..ef14a77 100644 (file)
@@ -62,6 +62,10 @@ class Sales_Frontend_Json extends Tinebase_Frontend_Json_Abstract
             $this->_relatableModels[] = 'Sales_Model_Invoice';
             $this->_configuredModels[] = 'InvoicePosition';
             $this->_configuredModels[] = 'Invoice';
+        } else {
+            if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
+                Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Invoices module disabled');
+            }
         }
         if (Sales_Config::getInstance()->featureEnabled(Sales_Config::FEATURE_OFFERS_MODULE)) {
             $this->_relatableModels[] = 'Sales_Model_Offer';
@@ -142,7 +146,8 @@ class Sales_Frontend_Json extends Tinebase_Frontend_Json_Abstract
      */
     public function searchContracts($filter, $paging)
     {
-        return $this->_search($filter, $paging, Sales_Controller_Contract::getInstance(), 'Sales_Model_ContractFilter', /* $_getRelations */ array('Sales_Model_Customer', 'Addressbook_Model_Contact', 'Sales_Model_CostCenter'));
+        return $this->_search($filter, $paging, Sales_Controller_Contract::getInstance(), 'Sales_Model_ContractFilter',
+            /* $_getRelations */ array('Sales_Model_Customer', 'Addressbook_Model_Contact', 'Sales_Model_CostCenter'));
     }
 
     /**
index 29d38a9..8fe6417 100644 (file)
@@ -33,7 +33,8 @@ Tine.Timetracker.TimeaccountEditDialog = Ext.extend(Tine.widgets.dialog.EditDial
         var salesApp = Tine.Tinebase.appMgr.get('Sales');
         this.useInvoice = salesApp
             && salesApp.featureEnabled('invoicesModule')
-            && Tine.Tinebase.common.hasRight('manage', 'Sales', 'invoices');
+            && Tine.Tinebase.common.hasRight('manage', 'Sales', 'invoices')
+            && Tine.Sales.Model.Invoice;
         Tine.Timetracker.TimeaccountEditDialog.superclass.initComponent.call(this);
     },
     
index 9c461a3..88aaab7 100644 (file)
@@ -101,7 +101,8 @@ Tine.Timetracker.TimesheetEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog
         var salesApp = Tine.Tinebase.appMgr.get('Sales');
         this.useInvoice = Tine.Tinebase.appMgr.get('Sales')
             && salesApp.featureEnabled('invoicesModule')
-            && Tine.Tinebase.common.hasRight('manage', 'Sales', 'invoices');
+            && Tine.Tinebase.common.hasRight('manage', 'Sales', 'invoices')
+            && Tine.Sales.Model.Invoice;
         
         Tine.Timetracker.TimesheetEditDialog.superclass.initComponent.apply(this, arguments);
     },