shows a warning if application of billable is not found
authorPhilipp Schüle <p.schuele@metaways.de>
Wed, 7 Oct 2015 11:25:01 +0000 (13:25 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Thu, 8 Oct 2015 08:25:34 +0000 (10:25 +0200)
... instead of running into an error

Change-Id: I94ede953033fa72e96ed6794a54b7e4d1de1cb38
Reviewed-on: http://gerrit.tine20.com/customers/2259
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
Tested-by: Philipp Schüle <p.schuele@metaways.de>
tine20/Sales/js/InvoicePositionPanel.js

index e9e4645..a3bd68f 100644 (file)
@@ -148,30 +148,34 @@ Tine.Sales.InvoicePositionPanel = Ext.extend(Ext.Panel, {
             var pseudoEditDialog = {record: pseudoRecord, app: this.app};
             
             var split = this.modelsOfAccountable[this.accountables[index]].split('_Model_');
-            var model = Tine[split[0]].Model[split[1]];
-            var accountableApplication = Tine.Tinebase.appMgr.get(split[0]);
-            var renderedSum = Tine.Sales.renderInvoicePositionQuantity(this.sumsPerAccountable[this.accountables[index]], null, pseudoRecord2);
-            var grid = new Tine.Sales.InvoicePositionGridPanel({
-                collapsible: true,
-                collapsed: true,
-                editDialog: pseudoEditDialog,
-                height: (mymonths.length > 1) ? 350 : 250, // if grid will be grouped, make it bigger
-                title: accountableApplication.i18n._(model.getRecordsName()) +
-                       ' (' + mypositions.length + ')' + ' - ' +
-                       accountableApplication.i18n._(mypositions[0]['unit']) + ': ' + renderedSum,
-                app: this.app,
-                i18nModelsName: accountableApplication.i18n._(model.getRecordsName()),
-                i18nUnitName: accountableApplication.i18n._(mypositions[0]['unit']), 
-                accountable: this.modelsOfAccountable[this.accountables[index]],
-                accountableApplication: accountableApplication,
-                invoiceId: this.invoiceId,
-                renderedSum: renderedSum,
-                renderedSumsPerMonth: renderedSumsPerMonth,
-                unitName: mypositions[0]['unit'],
-                groupField: (mymonths.length > 1) ? 'month' : null
-            });
-            
-            this.add(grid);
+            if (Tine[split[0]]) {
+                var model = Tine[split[0]].Model[split[1]];
+                var accountableApplication = Tine.Tinebase.appMgr.get(split[0]);
+                var renderedSum = Tine.Sales.renderInvoicePositionQuantity(this.sumsPerAccountable[this.accountables[index]], null, pseudoRecord2);
+                var grid = new Tine.Sales.InvoicePositionGridPanel({
+                    collapsible: true,
+                    collapsed: true,
+                    editDialog: pseudoEditDialog,
+                    height: (mymonths.length > 1) ? 350 : 250, // if grid will be grouped, make it bigger
+                    title: accountableApplication.i18n._(model.getRecordsName()) +
+                    ' (' + mypositions.length + ')' + ' - ' +
+                    accountableApplication.i18n._(mypositions[0]['unit']) + ': ' + renderedSum,
+                    app: this.app,
+                    i18nModelsName: accountableApplication.i18n._(model.getRecordsName()),
+                    i18nUnitName: accountableApplication.i18n._(mypositions[0]['unit']),
+                    accountable: this.modelsOfAccountable[this.accountables[index]],
+                    accountableApplication: accountableApplication,
+                    invoiceId: this.invoiceId,
+                    renderedSum: renderedSum,
+                    renderedSumsPerMonth: renderedSumsPerMonth,
+                    unitName: mypositions[0]['unit'],
+                    groupField: (mymonths.length > 1) ? 'month' : null
+                });
+
+                this.add(grid);
+            } else {
+                Tine.log.warn('Application for accountable ' + this.accountables[index] + ' not found!');
+            }
         }
     }
 });