diff --git a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-grid.js b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-grid.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-grid.js
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-grid.js
@@ -148,7 +148,7 @@
},
focusInFirstFilterEditor: function () {
- if (this.getFilterEditor()) { // there is a filter editor
+ if (this.getFilterEditor() && this.getFilterEditor().getEditForm()) { // there is a filter editor
var object = this.getFilterEditor().getEditForm(),
items, item, i, length;
@@ -326,7 +326,7 @@
var prop, fullPropName;
// make a copy so that we don't change the object
// which is maybe used somewhere else
- criteria = isc.clone(criteria);
+ criteria = criteria ? isc.clone(criteria) : {};
// If a criterion has been added to include the selected record, remove it
// See issue https://issues.openbravo.com/view.php?id=20722
criteria = this.removeSpecificIdFilter(criteria);
@@ -451,15 +451,21 @@
delete this.filterClause;
}
this.forceRefresh = true;
- this.filterEditor.getEditForm().clearValues();
+ if (this.filterEditor) {
+ if (this.filterEditor.getEditForm()) {
+ this.filterEditor.getEditForm().clearValues();
- // clear the date values in a different way
- length = this.filterEditor.getEditForm().getFields().length;
+ // clear the date values in a different way
+ length = this.filterEditor.getEditForm().getFields().length;
- for (i = 0; i < length; i++) {
- fld = this.filterEditor.getEditForm().getFields()[i];
- if (fld.clearDateValues) {
- fld.clearDateValues();
+ for (i = 0; i < length; i++) {
+ fld = this.filterEditor.getEditForm().getFields()[i];
+ if (fld.clearDateValues) {
+ fld.clearDateValues();
+ }
+ }
+ } else {
+ this.filterEditor.setValuesAsCriteria(null);
}
}
if (!noPerformAction) {
diff --git a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js
@@ -1062,6 +1062,12 @@
// and no additional filter clauses passed in
if (localState.filter && this.view.tabId !== this.view.standardWindow.additionalCriteriaTabId && this.view.tabId !== this.view.standardWindow.additionalFilterTabId) {
+ // a filtereditor but no editor yet
+ // set it in the initialcriteria of the filterEditro
+ if (this.filterEditor && !this.filterEditor.getEditForm()) {
+ this.filterEditor.setValuesAsCriteria(localState.filter);
+ }
+
this.setCriteria(localState.filter);
}
},
@@ -1438,6 +1444,8 @@
this.resetEmptyMessage();
this.view.updateTabTitle();
+ delete this.initialCriteria;
+
// do not refresh if the parent is not selected and we have no data
// anyway
if (this.view.parentProperty && (!this.data || !this.data.getLength || this.data.getLength() === 0)) {
@@ -1991,7 +1999,23 @@
if (!this.view) {
this.emptyMessage = this.noDataEmptyMessage;
} else if (this.isGridFiltered(criteria)) {
- this.emptyMessage = this.filterNoRecordsEmptyMessage;
+ // there can be some initial filters, but still no parent selected
+ if (this.view.parentView) {
+ selectedValues = this.view.parentView.viewGrid.getSelectedRecords();
+ parentIsNew = this.view.parentView.isShowingForm && this.view.parentView.viewForm.isNew;
+ parentIsNew = parentIsNew || (selectedValues.length === 1 && selectedValues[0]._new);
+ if (parentIsNew) {
+ this.emptyMessage = '' + OB.I18N.getLabel('OBUIAPP_ParentIsNew') + '';
+ } else if (!selectedValues || selectedValues.length === 0) {
+ this.emptyMessage = '' + OB.I18N.getLabel('OBUIAPP_NoParentSelected') + '';
+ } else if (selectedValues.length > 1) {
+ this.emptyMessage = '' + OB.I18N.getLabel('OBUIAPP_MultipleParentsSelected') + '';
+ } else {
+ this.emptyMessage = this.filterNoRecordsEmptyMessage;
+ }
+ } else {
+ this.emptyMessage = this.filterNoRecordsEmptyMessage;
+ }
} else if (this.view.isRootView) {
this.emptyMessage = this.noDataEmptyMessage;
} else {