Create / Scaffold a Module in Odoo

In this article, we introduce a command line that can create a module from scratch for Odoo (v10+).

Even though you can create a custom module manually by creating a new folder and its necessary files, it is faster to use the scaffold command. Furthermore, it auto-fills some fields for you.

Steps to Scaffold a Module

  • Open Command Prompt as Administrator.
  • Set the current directory to the folder which contains odoo-bin file. It is under “C:\Program Files (x86)\Odoo 12.0\server” in my case.
  • Run the following command
odoo-bin scaffold <module_name> <where to put it>
//example
odoo-bin scaffold my_first_module addons

There is a situation in which you encounter the following error.

'odoo-bin' is not recognized as an internal or external command,
operable program or batch file.

This happens because your machine has multiple Python versions installed or doesn’t have one run in the system’s environment. In this case, we need to execute odoo-bin from python.

"C:\Program Files (x86)\Odoo 12.0\python\python" "C:\Program Files (x86)\Odoo 12.0\server\odoo-bin" scaffold my_first_module addons/

The __manifest__.py file is where you need to update the module’s information.

# -*- coding: utf-8 -*-
{
    'name': "my_first_module",

    'summary': """
        Short (1 phrase/line) summary of the module's purpose, used as
        subtitle on modules listing or apps.openerp.com""",

    'description': """
        Long description of module's purpose
    """,

    'author': "My Company",
    'website': "http://www.yourcompany.com",

    # Categories can be used to filter modules in modules listing
    # Check https://github.com/odoo/odoo/blob/12.0/odoo/addons/base/data/ir_module_category_data.xml
    # for the full list
    'category': 'Uncategorized',
    'version': '0.1',

    # any module necessary for this one to work correctly
    'depends': ['base'],

    # always loaded
    'data': [
        # 'security/ir.model.access.csv',
        'views/views.xml',
        'views/templates.xml',
    ],
    # only loaded in demonstration mode
    'demo': [
        'demo/demo.xml',
    ],
}

Leave a Comment

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


Scroll to Top

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close