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 Window Action and Menuitem in Odoo 8 with Example – Odoo Technical
Creating Actions and Menuitem Odoo 8 tutorial

Greetings Everyone,

In this blog-post tutorial, you will learn how to create an Action and its Menuitem in an Odoo 8 module.

Type of Actions in Odoo:

  • Window Actions (ir.actions.act_window)
  • URL Actions (ir.actions.act_url)
  • Server Actions (ir.actions.server)
  • Report Actions (ir.actions.report.xml)
  • Client Actions (ir.actions.client)

Here we’ll learn about the Window Action.

What is Window Action in Odoo?

  • Window Actions are used to present visualisations of a model through views.
  • A window action defines a set of view types (and possibly specific views such as Tree, Form, Search) for a model (and possibly specific record of the model).

Example of Action and Menuitem :-

Earlier in my previous blog-posts, I created a student model, then I created its Form View followed by Tree View.  Now in this tutorial, I will create Action and Menuitem for it.

Code for creating an Action and its MenuItem:-

<!-- Action for Student Information -->
		<record id="action_student_information" model="ir.actions.act_window">
			<field name="name">Student Information</field>
			<field name="res_model">student.student</field>
			<field name="view_type">form</field>
			<field name="view_mode">tree,form</field>
		</record>

		<!-- Top bar menu -->
		<menuitem id="menu_college_main" name="College"/>
		<!-- Left Sidebar MenuHead -->
		<menuitem id="menu_student_main" name="Student" parent="menu_college_main"/>
		<!-- Left Sidebar Menu -->
		<menuitem id="menu_student_info" parent="menu_student_main" action="action_student_information"/>

Steps for creating Action:-

  • Window actions are stored in database table ir_act_window. So first, write record tag and give unique id and ir.actions.act_window model. See the above code for reference.
  • Next, the string given in ‘name’ will appear on the menuitem (if the string is not provided in menuitem). Here I have given ‘Student Information’.
  • Further, very important, provide your model name in ‘res_model’. This will link your action with your model. Here I have given ‘student.student’.
  • ‘view_mode’ will give sequence to your views. Here tree and form view will be displayed first and second, respectively.
  • When is action called? The action is called when you click on its related menuitem.

SnapShot of Eclipse IDE:-

Action-in-Odoo
Action-in-Odoo – Click to Enlarge

Steps for creating Menuitem:-

  • Menuitems are created by <menuitem> tag
  • Provide unique id in ‘id’.
  • Provide the id of the parent menu in ‘parent’. Here i wanted to show ‘Student’ under ‘College’, so I wrote the id of ‘College’ menuitem in ‘Student’ menutiem.
  • Write the id of the action just created above inside ‘action’ attribute. Here, ‘action_student_information’.

SnapShot of created Menuitem:-

Menuitem-tutorial-odoo-8
Menuitem-tutorial-odoo-8 – Click to enlarge

Hope you learnt how to create an Action and Menuitem 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..

I will update how to create Search view soon.

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 *