Merge pull request #4415 from expsa/eltayar

🛠️ [HOTFIX] odex25_base - إصلاح خطأ JavaScript في موديول البحث v2.2
This commit is contained in:
Mohamed Eltayar 2025-08-29 16:38:48 +03:00 committed by GitHub
commit 8ade7ca729
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 22 additions and 3 deletions

View File

@ -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