Merge PR #4421: Critical Fix for TypeError
Critical fix for TypeError in _renderBody function: - Added proper checking for Promise vs non-Promise returns - Fixed compatibility issues with Odoo 14 variations - Maintains all previous functionality (search preservation, pagination, etc.) - No more console errors when using the search module
This commit is contained in:
commit
7146c96da3
|
|
@ -38,15 +38,28 @@ odoo.define('fims_general_search_tree_view.list_search', function (require) {
|
|||
var searchValue = this._search ? this._search.value : '';
|
||||
var self = this;
|
||||
|
||||
return this._super.apply(this, arguments).then(function(result) {
|
||||
// Restore search value after render
|
||||
var result = this._super.apply(this, arguments);
|
||||
|
||||
// Check if result is a Promise
|
||||
if (result && typeof result.then === 'function') {
|
||||
return result.then(function(res) {
|
||||
// Restore search value after render
|
||||
if (searchValue) {
|
||||
setTimeout(function() {
|
||||
self._restoreSearchInput();
|
||||
}, 0);
|
||||
}
|
||||
return res;
|
||||
});
|
||||
} else {
|
||||
// If not a promise, restore immediately
|
||||
if (searchValue) {
|
||||
setTimeout(function() {
|
||||
self._restoreSearchInput();
|
||||
}, 0);
|
||||
}
|
||||
return result;
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
@ -403,7 +416,8 @@ odoo.define('fims_general_search_tree_view.list_search', function (require) {
|
|||
// Render new rows
|
||||
var result = this._renderBody();
|
||||
|
||||
if (result && result.then) {
|
||||
// Handle both promise and non-promise returns
|
||||
if (result && typeof result.then === 'function') {
|
||||
result.then(function() {
|
||||
self._forceRestoreSearchState();
|
||||
self.$('.oe_search_count').text(_t('Found: ') + records.length + _t(' records')).show();
|
||||
|
|
@ -670,7 +684,11 @@ odoo.define('fims_general_search_tree_view.list_search', function (require) {
|
|||
|
||||
// Re-render
|
||||
if (typeof this._renderBody === 'function') {
|
||||
this._renderBody();
|
||||
var result = this._renderBody();
|
||||
// Handle both promise and non-promise
|
||||
if (!result || typeof result.then !== 'function') {
|
||||
// Not a promise, already rendered
|
||||
}
|
||||
} else {
|
||||
// Show original rows with pagination
|
||||
var $rows = this.$('.o_data_row');
|
||||
|
|
|
|||
Loading…
Reference in New Issue