How to write a module in Odoo (part I – module structure)

How to write a module in Odoo (part I – module structure)

This is our tutorial on writing a custom module for your own need. In many cases, no, i will say most of cases that you won’t need to modify your Odoo application. It means it is almost impossible to use the standard package without any changes. There are many ways you can edit your application such as add a field from Odoo user interface or make change on xml view. If it can do that with Odoo user interface, why should we still need to make a custom module. The thing is when you try to upgrade a version,  module app will be easier to transfter and maintain all the data, data structure and complex functionalities. Another good thing is it won’t affect the core program and ease to debug.

1/. Create module structure

in Odoo, you can use odoo-bin  to create a default module structure, so that you don’t have to make by yourself.

./odoo-bin scaffold custom-module-name /yourpath/addons/

  • data folder: it contains css and xml files which hold to predefined information into the system like  a list of colourscounties, states name data.
  • models folder: it contains all python (.py) files. These hold models that newly created or inherit from other existing models, objects and the business logic as well.  In part 2, we will introduce it more detail.
  • security directory: it contains two files, Access control .csv file, Record rule .xml files. Access control: ir.model.access.csv must be there and used for holding access rights of model. Record Rules: security.xml that can declare the the prohibited operations like create, update and delete. This access control is applied in single record, so you need to specify which record is going to be applied.
  • views directory: it contains all .xml files where we declare the form views, menu, action, Qweb template and so on for our business objects.
  •  it is utilized to specify the directories or packages need to imported.
    from . import models			// folder
    from . import controllers		// folder
    from . import custom-module-nam		// file
  • this file is crucial in Odoo module. This module should be located at the root of the module. It lets you describe essential information of your module like name, version, description, dependencies, data files, etc.
    – Name – module name
    – Description – Brief description of your module
    – Version – Version of your module
    – License –  License of your module
    – Author – Author name of your module
    – Website – Website URL of your module author or company
    – Category – Indicate the category name.
    – Depends – Specifies a list of modules which need to install before this module. This is important. Without this declaration, you may get warning or error during module installation
    – Data – Data files which are always installed or updated with the module.
    – demo – Data files which are installed or updated in active demonstration mode.

There are no reviews yet.

Leave a Reply

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

The reCAPTCHA verification period has expired. Please reload the page.

Start typing and press Enter to search

slot gacor dana slot deposit dana