Deprecated: Return type of WP_Theme::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/odootech/domains/odootechnical.com/public_html/wp-includes/class-wp-theme.php on line 554

Deprecated: Return type of WP_Theme::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/odootech/domains/odootechnical.com/public_html/wp-includes/class-wp-theme.php on line 595

Deprecated: Return type of WP_Theme::offsetSet($offset, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/odootech/domains/odootechnical.com/public_html/wp-includes/class-wp-theme.php on line 535

Deprecated: Return type of WP_Theme::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/odootech/domains/odootechnical.com/public_html/wp-includes/class-wp-theme.php on line 544

Deprecated: Return type of WP_REST_Request::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/odootech/domains/odootechnical.com/public_html/wp-includes/rest-api/class-wp-rest-request.php on line 960

Deprecated: Return type of WP_REST_Request::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/odootech/domains/odootechnical.com/public_html/wp-includes/rest-api/class-wp-rest-request.php on line 980

Deprecated: Return type of WP_REST_Request::offsetSet($offset, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/odootech/domains/odootechnical.com/public_html/wp-includes/rest-api/class-wp-rest-request.php on line 992

Deprecated: Return type of WP_REST_Request::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/odootech/domains/odootechnical.com/public_html/wp-includes/rest-api/class-wp-rest-request.php on line 1003

Deprecated: Return type of WP_Block_List::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/odootech/domains/odootechnical.com/public_html/wp-includes/class-wp-block-list.php on line 151

Deprecated: Return type of WP_Block_List::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/odootech/domains/odootechnical.com/public_html/wp-includes/class-wp-block-list.php on line 175

Deprecated: Return type of WP_Block_List::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/odootech/domains/odootechnical.com/public_html/wp-includes/class-wp-block-list.php on line 164

Deprecated: Return type of WP_Block_List::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/odootech/domains/odootechnical.com/public_html/wp-includes/class-wp-block-list.php on line 186

Deprecated: Return type of WP_Block_List::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/odootech/domains/odootechnical.com/public_html/wp-includes/class-wp-block-list.php on line 138

Deprecated: Return type of WP_Block_List::offsetExists($index) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/odootech/domains/odootechnical.com/public_html/wp-includes/class-wp-block-list.php on line 75

Deprecated: Return type of WP_Block_List::offsetGet($index) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/odootech/domains/odootechnical.com/public_html/wp-includes/class-wp-block-list.php on line 89

Deprecated: Return type of WP_Block_List::offsetSet($index, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/odootech/domains/odootechnical.com/public_html/wp-includes/class-wp-block-list.php on line 110

Deprecated: Return type of WP_Block_List::offsetUnset($index) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/odootech/domains/odootechnical.com/public_html/wp-includes/class-wp-block-list.php on line 127

Deprecated: Return type of WP_Block_List::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/odootech/domains/odootechnical.com/public_html/wp-includes/class-wp-block-list.php on line 199

Deprecated: Return type of WPCF7_FormTag::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/odootech/domains/odootechnical.com/public_html/wp-content/plugins/contact-form-7/includes/form-tag.php on line 396

Deprecated: Return type of WPCF7_FormTag::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/odootech/domains/odootechnical.com/public_html/wp-content/plugins/contact-form-7/includes/form-tag.php on line 388

Deprecated: Return type of WPCF7_FormTag::offsetSet($offset, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/odootech/domains/odootechnical.com/public_html/wp-content/plugins/contact-form-7/includes/form-tag.php on line 382

Deprecated: Return type of WPCF7_FormTag::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/odootech/domains/odootechnical.com/public_html/wp-content/plugins/contact-form-7/includes/form-tag.php on line 400

Deprecated: Return type of WPCF7_Validation::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/odootech/domains/odootechnical.com/public_html/wp-content/plugins/contact-form-7/includes/validation.php on line 78

Deprecated: Return type of WPCF7_Validation::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/odootech/domains/odootechnical.com/public_html/wp-content/plugins/contact-form-7/includes/validation.php on line 72

Deprecated: Return type of WPCF7_Validation::offsetSet($offset, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/odootech/domains/odootechnical.com/public_html/wp-content/plugins/contact-form-7/includes/validation.php on line 59

Deprecated: Return type of WPCF7_Validation::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/odootech/domains/odootechnical.com/public_html/wp-content/plugins/contact-form-7/includes/validation.php on line 82

Deprecated: DateTime::__construct(): Passing null to parameter #1 ($datetime) of type string is deprecated in /home/odootech/domains/odootechnical.com/public_html/wp-includes/script-loader.php on line 348

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/odootech/domains/odootechnical.com/public_html/wp-includes/class-wp.php on line 173
Learn – How to create a Search View in Odoo 8 with Example – Odoo Technical
Creating Search VIew Odoo 8

Greetings Everyone,

In this blog-post tutorial, you will learn how to create a Search View in an Odoo 8 module.

What is Search View in Odoo?

  • A search view defines the search options that will be available in the views.

Which search options are available in Search View?

  • Define the ‘fields’ to be searched when a user types in the search box.
  • Set Predefined Filters.
  • Data Grouping options.

Example of a Search View :-

Earlier in my previous blog-post, I had created a Model to collect student’s information. Then I had created its From View and Tree View. Now I will create a Search View for the student model.

Code for creating a Search View

<!-- Search View for Student Information -->
		<record id="student_search_view" model="ir.ui.view">
			<field name="name">student.search.view</field>
			<field name="model">student.student</field>
			<field name="arch" type="xml">
				<search string="Student Information">
					<field name="name"/>
					<field name="email"/>
					<field name="contact"/>
					<group expand="0" string="Group By">
						<filter name="groupby_course" string="Course" domain="[]" context="{'group_by':'course_id'}"
							help="Group Students Course Wise"/>
						<filter name="groupby_year" context="{'group_by': 'registration_date:year'}" string="Year"
							help="Group Students by Year" />
						<filter name="groupby_month" context="{'group_by': 'registration_date:month'}" string="Month"/>
					</group>
					<filter name="fil_by_disability" string="Physically Disabled" domain="[('is_physically_disabled','=','True')]"
						help="Show all Physically Disabled Students" />
					<filter string="Registered Current Year" name="fil_by_current_year" domain="[('registration_date','&lt;=',
						time.strftime('%%Y-12-31')),('registration_date','&gt;=',time.strftime('%%Y-01-01'))]"
						help="Filter Students Registered in Current Year"/>
				</search>
			</field>
		</record>

 

Steps for creating Search View in Odoo

  • Add all the fields that you want to search when a user types in the search box. Here, I have added ‘name’, ’email’, ‘contact’ as searchable fields.
  • To add a Group By filter, add the field as a value in the ‘context’ dictionary with key ‘group_by’. Here, I have added Group by for ‘Course’, ‘Year’ and ‘Month’ .
  • To add a Domain Filter, add your domain in the ‘domain’ attribute. Here, I have added Domain Filter for ‘Physically Disabled’ and ‘Current Year’. By seeing the code you will come to know how to write your own domain.

SnapShot of Eclipse IDE:-

Search View Code Odoo 8
Search View Code Odoo 8 – Click to Enlarge

 

Search Box Odoo 8
Search Box Odoo 8

 

Group By and Domain Filters Odoo 8
Group By and Domain Filters Odoo 8 – Click to Enlarge

 

Hope you learnt how to create a Search View in Odoo module in this tutorial, your reviews/comments/suggestions/doubts are most welcomed, please comment in the section below, and subscribe to the newsletter to receive timely future updates of this blog.

Thank You.

By Burhan Vakharia

Having 6+ years of experience working on Odoo with projects covering several business verticles like Retail industry, Manufacturing, Service, Rental, Education, Medical and many more. I am having experience working on Odoo projects from several countries across the globe.

Leave a Reply

Your email address will not be published. Required fields are marked *