🔧 CRITICAL FIX: Replaced 'do_search' with correct 'search' event for proper record filtering
❌ IDENTIFIED ROOT CAUSE: - The main issue was using trigger_up('do_search') instead of trigger_up('search') - 'do_search' event doesn't exist or isn't handled properly in ListRenderer context - This caused the count to work (RPC calls succeeded) but records weren't filtered ✅ APPLIED CORRECT FIX: - Changed trigger_up('do_search') to trigger_up('search') - the standard Odoo way - Updated both search and clear methods to use the correct event - Maintained all other enhancements (RPC count, domain logic, Arabic support) - Kept proper error handling and fallbacks 🎯 TECHNICAL EXPLANATION: - In Odoo, ListRenderer should trigger 'search' events upward to the controller - The controller then handles the domain filtering and reloads the view - 'do_search' is used in different contexts (like SearchView), not ListRenderer - This fix ensures records are properly filtered while maintaining accurate count 🚀 EXPECTED RESULT: - Search count will continue to work (RPC call succeeds) - Records will now be properly filtered in the list view - Clear function will restore all records - All other features remain intact (Arabic support, field detection, etc.) This is the standard Odoo methodology for triggering search from rendered components.
This commit is contained in:
parent
025b5a687f
commit
4459479e4d
|
|
@ -162,7 +162,7 @@ odoo.define('fims_general_search_tree_view.list_search', function (require) {
|
|||
},
|
||||
|
||||
/**
|
||||
* ENHANCED: Perform search using proper Odoo mechanisms
|
||||
* FIXED: Perform search using CORRECT Odoo method
|
||||
*/
|
||||
_performSearch: function(value) {
|
||||
var self = this;
|
||||
|
|
@ -173,7 +173,7 @@ odoo.define('fims_general_search_tree_view.list_search', function (require) {
|
|||
return Promise.resolve();
|
||||
}
|
||||
|
||||
console.log('=== ENHANCED PERFORM SEARCH ===');
|
||||
console.log('=== FIXED PERFORM SEARCH ===');
|
||||
console.log('Search value:', value);
|
||||
console.log('Value length:', value ? value.length : 0);
|
||||
|
||||
|
|
@ -195,7 +195,7 @@ odoo.define('fims_general_search_tree_view.list_search', function (require) {
|
|||
return Promise.resolve();
|
||||
}
|
||||
|
||||
console.log('Starting enhanced search for model:', self.state.model);
|
||||
console.log('Starting FIXED search for model:', self.state.model);
|
||||
|
||||
// Store original domain only once
|
||||
if (!self._search.originalDomain && !self._search.isFiltered) {
|
||||
|
|
@ -205,22 +205,22 @@ odoo.define('fims_general_search_tree_view.list_search', function (require) {
|
|||
// Show loading
|
||||
self._showLoading(true);
|
||||
|
||||
// ENHANCED: Use proper Odoo search with count
|
||||
return self._searchWithCount(value).finally(function() {
|
||||
// FIXED: Use correct Odoo search method
|
||||
return self._searchWithCorrectMethod(value).finally(function() {
|
||||
self._showLoading(false);
|
||||
self._searchInProgress = false;
|
||||
console.log('=== Enhanced search completed ===');
|
||||
console.log('=== Fixed search completed ===');
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* ENHANCED: Search with accurate count using RPC
|
||||
* FIXED: Use the CORRECT Odoo search method that actually filters records
|
||||
*/
|
||||
_searchWithCount: function(value) {
|
||||
_searchWithCorrectMethod: function(value) {
|
||||
var self = this;
|
||||
|
||||
console.log('=== ENHANCED SEARCH WITH COUNT ===');
|
||||
console.log('=== USING CORRECT ODOO SEARCH METHOD ===');
|
||||
|
||||
// Build search domain
|
||||
var searchDomain = this._buildSearchDomain(value);
|
||||
|
|
@ -249,8 +249,9 @@ odoo.define('fims_general_search_tree_view.list_search', function (require) {
|
|||
// Update UI with accurate count
|
||||
self.$('.oe_search_count').text(_t('Found: ') + count + _t(' records')).show();
|
||||
|
||||
// STEP 2: Apply search using trigger_up
|
||||
self.trigger_up('do_search', {
|
||||
// STEP 2: THE CORRECT WAY - Use trigger_up with 'search' event
|
||||
// This is the proper way to trigger search in Odoo
|
||||
self.trigger_up('search', {
|
||||
domain: finalDomain,
|
||||
context: self.state.context || {},
|
||||
groupBy: self.state.groupedBy || []
|
||||
|
|
@ -264,7 +265,7 @@ odoo.define('fims_general_search_tree_view.list_search', function (require) {
|
|||
console.error('Error getting search count:', error);
|
||||
|
||||
// Fallback: still apply search without count
|
||||
self.trigger_up('do_search', {
|
||||
self.trigger_up('search', {
|
||||
domain: finalDomain,
|
||||
context: self.state.context || {},
|
||||
groupBy: self.state.groupedBy || []
|
||||
|
|
@ -278,12 +279,12 @@ odoo.define('fims_general_search_tree_view.list_search', function (require) {
|
|||
},
|
||||
|
||||
/**
|
||||
* ENHANCED: Clear search using proper Odoo method
|
||||
* FIXED: Clear search using CORRECT Odoo method
|
||||
*/
|
||||
_clearSearchInternal: function() {
|
||||
var self = this;
|
||||
|
||||
console.log('=== ENHANCED CLEAR SEARCH ===');
|
||||
console.log('=== FIXED CLEAR SEARCH ===');
|
||||
|
||||
// Clear UI immediately
|
||||
this.$('.oe_search_input').val('');
|
||||
|
|
@ -298,7 +299,8 @@ odoo.define('fims_general_search_tree_view.list_search', function (require) {
|
|||
// Use original domain to clear search
|
||||
var originalDomain = this._search.originalDomain || [];
|
||||
|
||||
this.trigger_up('do_search', {
|
||||
// FIXED: Use correct 'search' event instead of 'do_search'
|
||||
this.trigger_up('search', {
|
||||
domain: originalDomain,
|
||||
context: this.state.context || {},
|
||||
groupBy: this.state.groupedBy || []
|
||||
|
|
@ -307,7 +309,7 @@ odoo.define('fims_general_search_tree_view.list_search', function (require) {
|
|||
// Clear stored original domain
|
||||
this._search.originalDomain = null;
|
||||
|
||||
console.log('Search cleared using enhanced method');
|
||||
console.log('Search cleared using FIXED method');
|
||||
return Promise.resolve();
|
||||
},
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue