Merge pull request #4415 from expsa/eltayar
🛠️ [HOTFIX] odex25_base - إصلاح خطأ JavaScript في موديول البحث v2.2
This commit is contained in:
commit
8ade7ca729
|
|
@ -119,6 +119,18 @@ odoo.define('fims_general_search_tree_view.list_search', function (require) {
|
|||
// Get only visible and stored fields to avoid computed fields issues
|
||||
var fieldsToRead = this._getFieldsToRead();
|
||||
|
||||
// Build order string safely
|
||||
var orderBy = false;
|
||||
if (this.state.orderedBy && this.state.orderedBy.length > 0 && this.state.orderedBy[0]) {
|
||||
var order = this.state.orderedBy[0];
|
||||
if (order.name) {
|
||||
orderBy = order.name;
|
||||
if (order.asc !== undefined) {
|
||||
orderBy += order.asc ? ' ASC' : ' DESC';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Perform RPC search with specific fields only - NO LIMIT
|
||||
this._rpc({
|
||||
model: model,
|
||||
|
|
@ -129,7 +141,7 @@ odoo.define('fims_general_search_tree_view.list_search', function (require) {
|
|||
limit: false, // No limit - get all records
|
||||
offset: 0,
|
||||
context: this.state.context || session.user_context,
|
||||
order: this.state.orderedBy ? this.state.orderedBy[0].name : false
|
||||
order: orderBy
|
||||
}
|
||||
}).then(function(result) {
|
||||
self._updateListWithSearchResults(result, value);
|
||||
|
|
@ -150,7 +162,7 @@ odoo.define('fims_general_search_tree_view.list_search', function (require) {
|
|||
|
||||
// Get only visible, stored fields from columns
|
||||
_.each(this.columns, function(column) {
|
||||
if (!column.invisible && column.attrs.name) {
|
||||
if (!column.invisible && column.attrs && column.attrs.name) {
|
||||
var fieldName = column.attrs.name;
|
||||
var field = self.state.fields[fieldName];
|
||||
|
||||
|
|
@ -238,7 +250,7 @@ odoo.define('fims_general_search_tree_view.list_search', function (require) {
|
|||
|
||||
// Priority 1: Get visible stored fields from columns
|
||||
_.each(this.columns, function(column) {
|
||||
if (!column.invisible && column.attrs.name) {
|
||||
if (!column.invisible && column.attrs && column.attrs.name) {
|
||||
var fieldName = column.attrs.name;
|
||||
var field = self.state.fields[fieldName];
|
||||
|
||||
|
|
@ -310,6 +322,9 @@ odoo.define('fims_general_search_tree_view.list_search', function (require) {
|
|||
self.$el.find('.oe_search_input').val(self._currentSearchValue);
|
||||
self.$el.find('.oe_clear_search').show();
|
||||
$countEl.show();
|
||||
}).catch(function(error) {
|
||||
console.error('Error rendering search results:', error);
|
||||
self._showError(_t('Error displaying results'));
|
||||
});
|
||||
|
||||
} else {
|
||||
|
|
@ -367,6 +382,10 @@ odoo.define('fims_general_search_tree_view.list_search', function (require) {
|
|||
this.state.data.records = this._originalRecords;
|
||||
this._renderBody().then(function() {
|
||||
self._originalRecords = null;
|
||||
}).catch(function(error) {
|
||||
console.error('Error restoring original records:', error);
|
||||
// Just show all rows as fallback
|
||||
self.$el.find('.o_data_row').show();
|
||||
});
|
||||
} else {
|
||||
// Just show all rows
|
||||
|
|
|
|||
Loading…
Reference in New Issue