Building a Module with Odoo Module Development

ravi garg, mss, odoo, odoo module, odoo moduel development, odoo module development services

Odoo ERP is open-source and has a modular framework. The system includes multiple business applications such as POS, CRM, e-commerce, manufacturing, supply chain management, and more.

This blog explores creating a custom module in Odoo to align the platform with your business.

Understanding the Odoo modules

They are the building blocks of Odoo ERP software, and each module adds specific functionality to the system. You can install or uninstall these modules based on your needs. For instance, the CRM module is used to manage and track marketing, sales, and after-sales service. Another module, manufacturing, can help you manage production and ensure quality.

Creating a new module in Odoo?

Odoo allows you to build a business management system that is customized precisely to your requirements by selecting and installing the modules relevant to your operations. Here we’ll explore how you can create these modules in Odoo.

Composition of a module

The module is the combination of three aspects that come together to form the structure and functionality of an Odoo module.

  • Business objects – Business objects are also known as models that are defined using Python classes and represent the data structures that your module works with.
  • Object view – They define how the business objects are presented and interact with the Odoo user interface. They determine what users see on the screen and how they can create, read, update, and delete data. The object view is defined using XML files within the module. The XML definition specifies the field to display, its arrangement, the types of widgets to use, and the interface layout.
  • Data view – They are often defined in XML or CSV files in the data/ module directory. Data views are used to load initial or demonstration data into the business object when the module is installed or updated.

Module Structure

Each module follows a specific directory structure and includes certain key factors. These key files are:

  • __init__.py – This file makes a Python directory package and specifies which submodule to load.
  • __manifest__.py – The file contains metadata about the module, including its name, version, author, dependencies on other modules, description, and data to be loaded.
  • .py files (Python) – They contain Python code that defines the module’s data model, business logic, and server-side functionalities.
  • .xml files – They define the module’s user interface elements, including views (forms, lists, and kanban), menus, actions, and data templates.
  • Static/ directory – This directory includes static assets such as CSS, JavaScript, images, and fonts that the interface uses.
  • Data/ directory – The directory contains XML or CSV files to load initial data when the module is installed.
  • Reports/ directory – This directory contains definitions for custom reports.

Where to create a new module in Odoo?

The standard and recommended place to create a new module is within your Odoo addons path. The Odoo addons path is a directory where Odoo looks for modules.

Within the Odoo installation’s addons Directory

It is generally not recommended for customizations. You’ll find an addons directory within your odoo installation folder. This directory contains the official Odoo modules and any community modules you have installed through the Odoo Apps store. Technically, you can not create a new module within add-ons directory, and it is not recommended practice for your custom modules. Reasons why it is not recommended:

  • Mixing your custom code with Odoo’s core and community code can make your file structure messy and hard to manage.
  • Custom modules might get overwritten or cause conflict with the new version when updating the system.
  • It is difficult to keep track of custom changes separately from the base Odoo code.

Creating a separate custom addons path (recommended)
This is used to create one or more separate directories to house your custom odoo modules. You can configure Odoo to recognize these directories as additional addons. You can create this directory anywhere on your server or development machine where Odoo has read access. Some of the common locations are:

  • Subdirectory within your Odoo installation (outside the main addons directory)
  • Completely separate location in your file system (/opt/odoo_custom_addons or ~/odoo_custom_addons)

You need to tell odoo about the location of these files. This is done via the Odoo configuration file (odoo.conf or openerp-server.conf). Steps to do so:

  • Open the Odoo configuration file.
  • Search the addons path parameter.
  • Add the absolute path to your custom addons directory to the existing list of paths, separated by commas.

Note* The Odoo server should have the necessary permissions for your custom addons directory.

Maximize your growth potential with our innovation solutions.

Book your call to discuss your requirements!

Steps to create and install a module in Odoo

After setting up your custom addon path, we’ll create and then install your new Odoo module.

Creating the module structure

  • Navigate to your custom addons directory
    Open file explorer or terminal and go to the directory you have designated for your custom Odoo modules.
  • Create a new directory for your module.
    Choose a unique and descriptive name for your module. Convention is to use lowercase letters and underscores. For example – “mastersoftware_solutions_module”

Create the essential files.

You’ll need two files within your module’s directory. One is __nit__ .py and the other is __manifest __.py.

  • “__init__ .py” makes a Python package of a directory.
  • Open “ __nit__.py” with a text editor and add the following line – “from. import models”. (If you plan to have Python files directly in your module directory)
  • _manifest_ .py” contains the module metadata.
  • Open “__ manifest__.py” with a text editor and add a dictionary containing the module’s information.

Explaining “__manifest__.py” keys:

  • Name – User-friendly name of your module.
  • Version – The module’s version number.
  • Summary – A short, one-line description.
  • Description – Detailed explanation of the module.
  • Author – Your name or company name.
  • Website – Your website address.
  • Category – The Odoo module category.
  • Depends – A list of other Odoo modules that the module relies on. ‘Base’ is a good starting point.
  • Data – List of XML files that define views, actions, menus, and other data. During installation or upgrade, you need to load this data.
  • Demo – It is a list of XML files containing demo data.
  • Installable – Set to “true” if the module can be installed through the Odoo interface.
  • Application – Set to “true” if this module represents main apps (sales, inventory, or purchases)
  • auto-install – If this module should get auto-installed when all the dependencies are met, set it to “true”.

Installing the module in Odoo

Restart the Odoo server
Once you have created your module directory and files, you need to restart the Odoo service. This enables it to recognize the new module in your custom addons path.

Update the module list in the module

  • Log in to your Odoo instance as an administrator
  • Go to Settings under the “technical” menu if you have developer mode on.
  • Click on Update App List. Then the Odoo scans the addons path for new and updated modules.

Search for your module

  • Go to the Apps menu.
  • Search for your module. You can type the name of the module in the search bar.

Install your module

  • Click on the module to view its details.
  • Click the Install button. Odoo will install the module, create necessary database tables based on your models, load data defined in your data views, and apply defined views and security rules.

How can Master Software Solutions help with Odoo module development?

Master Software Solutions is an Odoo consulting company, that offers end-to-end Odoo services. We have 13+ years of experience and a team of 90+ tech experts. Our team possesses extensive knowledge and skills in Odoo’s technical and functional aspects, enabling us to assist you with Odoo module development. We offer Odoo module development services, including core processes development, industry-specific module development, UI and UX enhancement, and module app development. Contact us to discuss your business and see how we can help you.