Merge pull request #4449 from expsa/eltayar
Fix: Prevent search box in Many2Many/One2Many fields - فحص parentID
This commit is contained in:
commit
f8ae7d58b2
|
|
@ -390,7 +390,7 @@ odoo.define('fims_general_search_tree_view.list_search', function (require) {
|
|||
},
|
||||
|
||||
_shouldAddSearchBox: function() {
|
||||
// Basic requirements check
|
||||
// التحقق من المتطلبات الأساسية
|
||||
if (!this.arch ||
|
||||
this.arch.tag !== 'tree' ||
|
||||
!this.$el ||
|
||||
|
|
@ -399,45 +399,19 @@ odoo.define('fims_general_search_tree_view.list_search', function (require) {
|
|||
return false;
|
||||
}
|
||||
|
||||
// Check if this is inside a relational field (Many2Many/One2Many)
|
||||
// Look for parent containers that indicate we're inside a form field
|
||||
var $parent = this.$el.parent();
|
||||
// الحل الدقيق الوحيد المؤكد:
|
||||
// فحص الـ model state للـ ListRenderer
|
||||
var controller = this.getParent();
|
||||
if (controller && controller.model && controller.handle) {
|
||||
var state = controller.model.get(controller.handle);
|
||||
|
||||
// Check for various indicators that we're inside a relational field
|
||||
while ($parent.length > 0) {
|
||||
// Check if parent has classes that indicate it's a field widget
|
||||
if ($parent.hasClass('o_field_widget') ||
|
||||
$parent.hasClass('o_field_many2many') ||
|
||||
$parent.hasClass('o_field_one2many') ||
|
||||
$parent.hasClass('o_field_x2many_list') ||
|
||||
$parent.hasClass('o_x2many_control_panel') ||
|
||||
$parent.attr('name') && $parent.closest('.o_form_view').length > 0) {
|
||||
return false; // Don't show search box in relational fields
|
||||
// إذا كان parentID موجود، فهذا يعني أن الـ list embedded داخل relational field
|
||||
if (state && state.parentID) {
|
||||
return false; // لا نظهر البحث للـ embedded lists
|
||||
}
|
||||
}
|
||||
|
||||
// Check if we're inside a form view (not a standalone list view)
|
||||
if ($parent.hasClass('o_form_view') &&
|
||||
this.$el.closest('.o_content').find('.o_form_view').length > 0) {
|
||||
return false; // Don't show in embedded lists within forms
|
||||
}
|
||||
|
||||
// Stop at main content area
|
||||
if ($parent.hasClass('o_content') ||
|
||||
$parent.hasClass('o_action_manager') ||
|
||||
$parent.hasClass('o_main_content')) {
|
||||
break;
|
||||
}
|
||||
|
||||
$parent = $parent.parent();
|
||||
}
|
||||
|
||||
// Additional check: if the list is very small (likely embedded), don't show
|
||||
if (this.$el.find('tbody tr').length <= 5 &&
|
||||
this.$el.closest('.o_form_view').length > 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true; // Show search box for standalone list views
|
||||
return true; // نظهر البحث للـ standalone lists فقط
|
||||
},
|
||||
|
||||
_addCustomSearchBox: function() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue