{"id":9200,"date":"2024-09-24T07:15:13","date_gmt":"2024-09-24T07:15:13","guid":{"rendered":"https:\/\/www.infinitivehost.com\/knowledge-base\/?p=9200"},"modified":"2024-09-24T08:35:19","modified_gmt":"2024-09-24T08:35:19","slug":"odoo-16-searchpanel-default-state-configuration-guide","status":"publish","type":"post","link":"https:\/\/www.infinitivehost.com\/knowledge-base\/odoo-16-searchpanel-default-state-configuration-guide\/","title":{"rendered":"Odoo 16 SearchPanel Default State Configuration Guide"},"content":{"rendered":"<div class='epvc-post-count'><span class='epvc-eye'><\/span>  <span class=\"epvc-count\"> 2,836<\/span><span class='epvc-label'> Views<\/span><\/div>\n<p class=\"wp-block-paragraph\">In Odoo 16, the <strong>SearchPanel<\/strong> is a powerful tool for filtering records within list, kanban, and other views. You can configure its default state to define which filters or groups are shown by default when the view is loaded.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here\u2019s how you can configure the <strong>default state<\/strong> of the SearchPanel in Odoo 16:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. XML View Definition<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">You can configure the <strong>SearchPanel<\/strong> in the view&#8217;s XML file using the <code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">search_panel<\/mark><\/code> tag within the <code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">search<\/mark><\/code> view. The <strong>default state<\/strong> involves specifying which fields are pre-filtered or shown in the Search Panel when a view is initially opened.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2. Basic Example for SearchPanel Configuration:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code><code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">&lt;record id=\"view_your_model_tree\" model=\"ir.ui.view\">\n    &lt;field name=\"name\">your.model.tree&lt;\/field>\n    &lt;field name=\"model\">your.model&lt;\/field>\n    &lt;field name=\"arch\" type=\"xml\">\n        &lt;tree>\n            &lt;!-- Define your tree structure here -->\n        &lt;\/tree>\n        &lt;search>\n            &lt;search_panel>\n                &lt;!-- Filter on a many2one field -->\n                &lt;field name=\"your_many2one_field\" \n                       string=\"Category\" \n                       default_group_by=\"True\" \/>\n\n                &lt;!-- Filter on a date field -->\n                &lt;field name=\"your_date_field\" \n                       string=\"Date\"\n                       filter=\"day\"\n                       default_filter=\"this_month\" \/>\n            &lt;\/search_panel>\n        &lt;\/search>\n    &lt;\/field>\n&lt;\/record><\/mark><\/code><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Key Attributes in the SearchPanel:<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>default_group_by<\/strong>: Defines if the records should be grouped by this field by default.<\/li>\n\n\n\n<li><strong>default_filter<\/strong>: Specifies a default filter, especially for date fields (e.g., <code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">\"this_month\"<\/mark><\/code>, <code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">\"today\"<\/mark><\/code>, etc.).<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">3. Default State Filters:<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">You can set default filters for specific fields, especially date filters. Here\u2019s an example where we set a default filter on a date field:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">&lt;search_panel>\n    &lt;field name=\"your_date_field\" \n           string=\"Creation Date\" \n           filter=\"day\"\n           default_filter=\"today\"\/>\n&lt;\/search_panel><\/mark><\/code><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">4. Full Example:<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">In this example, we have both a <code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">many2one<\/mark><\/code> field filter and a <code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">date<\/mark><\/code> field filter, and they are both configured with default values.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">&lt;record id=\"view_your_model_tree\" model=\"ir.ui.view\">\n    &lt;field name=\"name\">your.model.tree&lt;\/field>\n    &lt;field name=\"model\">your.model&lt;\/field>\n    &lt;field name=\"arch\" type=\"xml\">\n        &lt;tree>\n            &lt;!-- Tree structure -->\n        &lt;\/tree>\n        &lt;search>\n            &lt;search_panel>\n                &lt;field name=\"category_id\"\n                       string=\"Category\"\n                       default_group_by=\"True\" \/>\n                &lt;field name=\"create_date\"\n                       string=\"Creation Date\"\n                       filter=\"day\"\n                       default_filter=\"this_week\" \/>\n            &lt;\/search_panel>\n        &lt;\/search>\n    &lt;\/field>\n&lt;\/record><\/mark><\/code><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">5. Available Filters:<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">For date fields, you can set default filters like:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">\"today\"<\/mark><\/code><\/li>\n\n\n\n<li><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">\"yesterday\"<\/mark><\/code><\/li>\n\n\n\n<li><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">\"this_week\"<\/mark><\/code><\/li>\n\n\n\n<li><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">\"this_month\"<\/mark><\/code><\/li>\n\n\n\n<li><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">\"this_year\"<\/mark><\/code><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Conclusion<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">While using Odoo 16, the SearchPanel is one of the most robust tool for filtering all records inside the specific list, kanban, and some other views. You can easily setup its <strong>default state<\/strong> to describe which groups or filters are displayed on the screen by default. Here are some above-mentioned steps that helps you to setup of the SearchPanel in the case of Odoo with <a href=\"https:\/\/www.infinitivehost.com\/managed-odoo-server-solutions\"><mark style=\"background-color:#8ed1fc\" class=\"has-inline-color\"><strong>managed odoo server solutions<\/strong><\/mark><\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>2,836 Views In Odoo 16, the SearchPanel is a powerful tool for filtering records within list, kanban, and other views. You can configure its default state to define which filters or groups are shown by default when the view is loaded. Here\u2019s how you can configure the default state of the SearchPanel in Odoo 16: [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[203],"tags":[],"class_list":["post-9200","post","type-post","status-publish","format-standard","hentry","category-odoo"],"_links":{"self":[{"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/posts\/9200","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/comments?post=9200"}],"version-history":[{"count":2,"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/posts\/9200\/revisions"}],"predecessor-version":[{"id":9204,"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/posts\/9200\/revisions\/9204"}],"wp:attachment":[{"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/media?parent=9200"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/categories?post=9200"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/tags?post=9200"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}