forked from Techsystech/web
[IMP] web_widget_one2many_product_picker: Allow set first active group instead of set All by default
parent
a4ebc6fd54
commit
86ff396e8e
|
@ -81,8 +81,9 @@ odoo.define("web_widget_one2many_product_picker.FieldOne2ManyProductPicker", fun
|
||||||
|
|
||||||
// FIXME: Choose a better way to get the active controller or model objects
|
// FIXME: Choose a better way to get the active controller or model objects
|
||||||
this.parent_controller = parent.getParent();
|
this.parent_controller = parent.getParent();
|
||||||
|
this.indexGroup = 0;
|
||||||
if (this.view) {
|
if (this.view) {
|
||||||
this._processGroups();
|
this.indexGroup = this._processGroups();
|
||||||
}
|
}
|
||||||
|
|
||||||
this._currentSearchBatchID = 0;
|
this._currentSearchBatchID = 0;
|
||||||
|
@ -127,7 +128,7 @@ odoo.define("web_widget_one2many_product_picker.FieldOne2ManyProductPicker", fun
|
||||||
// Show Lines
|
// Show Lines
|
||||||
self._updateSearchContext(-1);
|
self._updateSearchContext(-1);
|
||||||
} else {
|
} else {
|
||||||
self._updateSearchContext(0);
|
self._updateSearchContext(self.indexGroup);
|
||||||
}
|
}
|
||||||
self._searchContext.text = "";
|
self._searchContext.text = "";
|
||||||
});
|
});
|
||||||
|
@ -268,13 +269,15 @@ odoo.define("web_widget_one2many_product_picker.FieldOne2ManyProductPicker", fun
|
||||||
*/
|
*/
|
||||||
_processGroups: function() {
|
_processGroups: function() {
|
||||||
this.searchGroups = [];
|
this.searchGroups = [];
|
||||||
|
var activeIndex = 0;
|
||||||
var hasUserActive = false;
|
var hasUserActive = false;
|
||||||
var groups = this.options.groups;
|
var groups = this.options.groups;
|
||||||
for (var groupIndex in groups) {
|
for (var groupIndex in groups) {
|
||||||
var group_def = groups[groupIndex];
|
var group_def = groups[groupIndex];
|
||||||
if (group_def.active) {
|
if (group_def.active && !hasUserActive) {
|
||||||
group_def.active = !hasUserActive;
|
|
||||||
hasUserActive = true;
|
hasUserActive = true;
|
||||||
|
// Set index + 1 because the first position is for All option
|
||||||
|
activeIndex = parseInt(groupIndex) + 1;
|
||||||
}
|
}
|
||||||
if (!group_def.records_per_page) {
|
if (!group_def.records_per_page) {
|
||||||
group_def.records_per_page = 16;
|
group_def.records_per_page = 16;
|
||||||
|
@ -290,7 +293,8 @@ odoo.define("web_widget_one2many_product_picker.FieldOne2ManyProductPicker", fun
|
||||||
active: !hasUserActive,
|
active: !hasUserActive,
|
||||||
records_per_page: 16,
|
records_per_page: 16,
|
||||||
});
|
});
|
||||||
this._activeSearchGroup = this.searchGroups[0];
|
this._activeSearchGroup = this.searchGroups[activeIndex];
|
||||||
|
return activeIndex;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue