How To Create or Develop a Custom Module in Odoo 11
In this blog, we‘ll be focusing on how we can create or develop a custom module in odoo. Moreover, we'll also discuss how we can design the view in this module.
In Odoo Development, Odoo Modules can either add brand new business logic to an Odoo System or alter and extend existing business logic. A module can be created to add your country’s accounting rules to Odoo’s generic accounting support, while the next module adds support for real-time visualization of a bus fleet.
In Odoo Development, Odoo Modules can either add brand new business logic to an Odoo System or alter and extend existing business logic. A module can be created to add your country’s accounting rules to Odoo’s generic accounting support, while the next module adds support for real-time visualization of a bus fleet.
Everything in Odoo thus starts and ends with modules.
Structure of a Module:
An Odoo module can contain many elements like:
Objects/Models: Declared as Python classes, these resources are automatically persisted by Odoo based on their configuration
View Files: XML or CSV files declaring metadata (views or reports), configuration data (modules parameterization), demonstration data and more
Controllers: Are used to handling requests from web browsers
Static Web Data: Images, CSS or JavaScript files used by the web interface or website
In this case, we‘ll be focusing on how to generate a simple custom module using python models & XML views. So, let us start first by naming our custom module.
We can name this custom module whatever we want, but it should be related to the functioning of the module so that, it is user-friendly as well.
In this case, we will create a simple book module. So, let us name this folder as sample_book:
Now we need to create some sub-folders and sub-files inside this module. The final structure will be like this:
- models
- __init__.py
- sample_book.py
- views
- sample_book_view.xml
- __init__.py
- __manifest__.py
Inside each file, type it like this:
- models/__init__.py
thats all we need, now start the server and the Book module is now ready to install. :D