Odoo: Open-Source ERP and Module Scaffolding

This article provides a detailed guide on how to scaffold and customize a new module in Odoo 10 and later versions, including common issues and troubleshooting tips.

Binary Buddies · 5 min read · 5 views

Odoo is a powerful open-source ERP (Enterprise Resource Planning) suite designed to streamline business operations. Companies of all sizes use Odoo to manage their CRM, website building, eCommerce, warehouse management, project management, billing, accounting, point of sale, human resources, marketing, and manufacturing. While Odoo provides a robust set of features out-of-the-box, setting up and customizing it can be challenging. This article focuses on how to scaffold a new module in Odoo 10 and later versions, a common task for developers and administrators.

The scaffolding process generates the basic structure of a new module, saving developers time and ensuring a consistent starting point. However, this process can encounter several issues, such as missing files or incorrect commands. Understanding these issues and their resolutions is crucial for a smooth development experience.

Understanding Odoo Scaffolding

Odoo scaffolding is a tool that helps developers quickly set up the basic structure of a new module. This is particularly useful for creating custom modules that integrate with Odoo's core functionalities. Prior to Odoo 10, the scaffolding command was executed using oe or odoo.py. However, in Odoo 10 and later versions, the command has changed to odoo-bin.

To scaffold a new module, navigate to your Odoo installation directory. For example, if your Odoo installation is located at /opt/odoo, you would use the following command:

cd /opt/odoo

Once in the correct directory, execute the scaffolding command:

./odoo-bin scaffold my_new_module ./addons/

Replace my_new_module with the desired name of your module and ./addons/ with the path to your Odoo addons directory. This command will create a new module structure in the specified directory.

Customizing the New Module

After scaffolding, the next step is to customize the newly created module. The most important file to edit is __openerp__.py, which contains metadata about your module. You can use a text editor like nano to modify this file:

nano ./addons/my_new_module/__openerp__.py

Here, you can set a user-friendly name for your module, add a description, and specify dependencies. For example:

{
    'name': 'Andrius's New Module',
    'description': 'A custom module to extend Odoo functionality',
    'depends': ['base', 'mail'],
}

Next, you can add custom models and logic to your module. For instance, you might want to extend an existing model. Open the models.py file:

nano ./addons/my_new_module/models.py

Add your custom code to this file. As an example, the following code extends the mail.notification model to remove the signature footer:

from openerp import models, api

class FooterlessNotification(models.Model):
    _inherit = 'mail.notification'
    
    @api.model
    def get_signature_footer(self, user_id, res_model=None, res_id=None, context=None, user_signature=True):
        return ''

Installing the New Module

Once your module is customized, it needs to be installed in Odoo. You can do this through the Odoo settings. First, update the module list to ensure Odoo recognizes your new module:

  • Navigate to Apps in the Odoo interface.
  • Click on Update Apps List.

If you cannot find the Update Apps List option, you may need to enable technical features for your user:

  • Go to Settings > Users > Users.
  • Select your user and click Edit.
  • Check the Technical Features checkbox.

After updating the module list, search for your new module and install it. You may need to remove the Applications tag from the search box filter to see all available modules.

Common Issues and Troubleshooting

During the scaffolding and installation process, you may encounter several issues. Here are some common problems and their solutions:

  • Missing odoo-bin command: Ensure that you are in the correct Odoo installation directory. The odoo-bin file should be located in the root of your Odoo installation.
  • Module not appearing in the Apps list: Make sure you have updated the module list and that technical features are enabled for your user.
  • Permissions issues: Ensure that the user running the Odoo service has the necessary permissions to read and write in the addons directory.

If you encounter any other issues, consult the Odoo documentation or community forums for additional help.

Limits and Considerations

While Odoo scaffolding is a powerful tool, it has its limitations and considerations. Here are a few points to keep in mind:

  • Customization complexity: Scaffolding provides a basic structure, but complex customizations may require additional development work. Ensure you have a good understanding of Odoo's architecture and Python programming.
  • Dependency management: When adding dependencies to your module, be cautious about version compatibility. Some dependencies may not be compatible with the version of Odoo you are using.
  • Performance impact: Custom modules can affect the performance of your Odoo instance, especially if they are not optimized. Regularly test your modules to ensure they do not slow down your system.

By being aware of these limitations, you can better plan and execute your custom module development in Odoo.

This article draws on Odoo - scaffolding? and answers to it (1, 2), on the Stack Exchange network, licensed under CC BY-SA 4.0.

  • #ERP
  • #Open Source
  • #custom module
  • #development
  • #module scaffolding
  • #odoo

Comments

Add a comment
Sign in with Google to join the conversation