Tuesday, 7 September 2021

How to create an Odoo custom module in one command?

While creating a new Odoo custom module, it is a nightmare to do copy & paste, edit & delete files, folders, icons, readme, manifest file etc.

By default Odoo provides a super cool command called scaffold to help you in this situation.

What is Odoo Scaffolding?

Scaffolding is the automated creation of a skeleton structure to simplify bootstrapping (of new modules, in the case of Odoo). While not necessary it avoids the tedium of setting up basic structures and looking up what all starting requirements are.

Scaffolding is available via the odoo-bin scaffold subcommand.

-t <template>

a template directory, files are passed through jinja2 then copied to the destination directory

name

the name of the module to create, may munged in various manners to generate programmatic names (e.g. module directory name, model names, …)

destination

directory in which to create the new module, defaults to the current directory

 

I have built a few custom module templates as per different categories to manage it.

For example, 

  1. If I want to create a new web related custom module, then I manage it under the web_custom_addons_template module.  
  2. If I want to create a new non-web related custom module, then I manage it under standard_custom_addons_template. 
  3. If I want to create a new customer (project related) custom module, then I manage it under project-code_custom_addons_template
  4. If I want to create a new company (generic) related custom module, then I manage it under company-prefix-custom_addons_template
  5. If I want to create a new OCA related custom module, then I manage it under oca_custom_addons_template


In these template modules, I maintain different manifest files and folders (web/non-web controllers/generic/customer/company). This will save a lot of time to modify/delete files & folders, icons compared to Odoo standard generic custom module template.

Here is command to generate Odoo custom module: 

./odoo-bin scaffold -t source_custom_module_name new_custom_module_name destination_path

where

source_custom_module_name is one of my 4 options. It can vary in your module management.

new_custom_module_name is unique module name based on what I extend workflow

destination_path in which create the new module


I hope you like this article. Share your views. Happy Learning !!!

 

Reference link: https://docs.huihoo.com/odoo/developer/12.0/reference/cmdline.html#scaffolding

No comments:

Post a Comment

ImportError: cannot import name 'utils' from 'PyPDF2'

Odoo 15: Traceback (most recent call last):   File "/usr/local/lib/python3.8/threading.py", line 932, in _bootstrap_inner     self...