26

I read here that you can scaffold a module using a command, so you won't need to manually create some initial files. But such command does not work on master (on Odoo development branch):

./oe scaffold Academy ../my-modules

Because there is no such file called oe in openerp directory. Did this thing change in the newest version? How can I scaffold a module in Odoo?

Kenly
  • 16,220
  • 5
  • 36
  • 52
Andrius
  • 15,319
  • 31
  • 125
  • 205
  • Please tell me on which path you are writing this command. Because previously it was written on server directory but now oe file is available in the odoo directory so if you have downloaded from github.com/odoo/odoo then it will show you oe file in odoo itself. – Bazzinga... Jun 24 '14 at 12:09
  • Yeah, I downloaded from there. And tried to run from odoo, but there is no such file called oe. How should I run from odoo directory? – Andrius Jun 24 '14 at 12:27
  • Sorry to say but it is not yet updated in odoo/odoo, but if you want to just learn then you can use old openerp from here, Server:https://code.launchpad.net/~openerp/openobject-server/trunk Addons:https://code.launchpad.net/~openerp/openobject-addons/trunk Web:https://code.launchpad.net/~openerp/openerp-web/trunk – Bazzinga... Jun 24 '14 at 13:05
  • 1
    Thanks for update. Well the point is I want to learn all new stuff that is in Odoo :). So I guess I'll need to manually create initial files or write some script myself. – Andrius Jun 24 '14 at 13:12

17 Answers17

31

Now odoo 10 or later version use odoo-bin insted of odoo.py

  1. On the shell or terminal, change directory to your odoo folder. Maybe it's in /opt/odoo, or maybe it's in /home/odoo :

    cd /opt/odoo
    
  2. Create a new module using the odoo.py script:

    ./odoo.py scaffold my_new_module ./addons/
    

(where my_new_module is a name of your new module, and ./addons/ is the Odoo addons directory)

  1. Edit the ./addons/my_new_module/__openerp__.py file.

    nano ./addons/my_new_module/__openerp__.py
    
  2. Change the name field to set a user friendly name of your module (for example "Andrius's New Module"). Change description and fields also. And add your needed modules, such as 'mail', to the to the list of module dependencies depends.

    'depends': ['base', 'mail'],
    
  3. Edit models.py

    nano ./addons/my_new_module/models.py
    
  4. Add code in your my_new_module/models.py file, for example:

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 ""

(As an example, this code will extend the 'mail.notification' model and replace its get_signature_footer method with one that returns an empty footer.)

  1. Install your module via Odoo settings.

To find it there you may need to use the "Update Module List" option.

If you can't find the option "Update Module List" either, you may need to enable the "Technical Features" checkbox in your current user's settings.

To display Modules, not just the Applications, remove the tag "Applications" from the search box filter, by clicking the small "x" before the tag.

Virbhadrasinh
  • 519
  • 5
  • 19
Chris Coleman
  • 486
  • 1
  • 5
  • 9
8

You can use ./odoo-bin scaffold MODULE_NAME PATH_TO_STORE_YOUR_MODULE_OR_ADDONS

For example: ./odoo-bin scaffold module_name /odoo/odoo-server/custom_addons/

Here custom_addons is your directory in odoo-server/

cmd in Odoo10:

./odoo-bin scaffold <module_name> <destination path where you want to create> 
Ismail H Rana
  • 352
  • 1
  • 9
Madhur Gupta
  • 104
  • 1
  • 8
5

Use odoo.py instead of oe:

./path/to/odoo/odoo.py scaffold my-module
Daniel Reis
  • 11,890
  • 5
  • 41
  • 69
1

From odoo documentation correct way to create a module is following:

odoo.py scaffold [name of module] [desired path of module]

Also I recommend you to use different addons path for your module and don't use odoo/addons, you can create a new directory where you want and then add this directory to odoo configuration or execute odoo with this addon from launch

odoo.py --addons-path=[full path to your dir]
1

I have installed ODOO 9 in AWS in the directory /opt/odoo.

So first I change directory:

 cd /opt/odoo

then executed:

 odoo.py scaffold modulename ./addons/

gives the following error msg:

 odoo.py command not found

the correct command that works for me is:

 sudo python odoo.py scaffold modulename ./addons/

Hope this helps.

Jaf Faizal
  • 51
  • 4
1

./"path to odoo.py file"/odoo.py scaffold my-module ./"path for your new addon"/

replace qoutes with your path

0

Another version

\###### begin ########

import sys

from openerp.cli import scaffold

sf = scaffold.Scaffold()

sf.run (sys.argv[1:])

\####### end #########

Save the script at the top to your openerp folder. Then execute with:

$ python (your-script-name) --help

or:

$ python (the-script-name) --init Academy --dest my-modules --model academy --controller academy --web --theme
JustinJDavies
  • 2,552
  • 2
  • 28
  • 50
0

Did you install as source or package.

For source you need to do

./odoo.py scaffold [module_name] [where_to_put_it]

if from package you need to do

 odoo.py scaffold [module_name] [where_to_put_it]

[where_to_put_it] usually is your addons path, your addons path may vary according to your install method.

It is not necessary to create the module in the addons folder. But it is recommended to do so.You can add the new addons path by

odoo.py --addons-path=[where_to_put_it]

For Module structure reference and for building a module.

maharshi
  • 572
  • 11
  • 27
0

In some cases, it is necessary to pass the Odoo python file to the Python application to execute.

python odoo.py scaffold modulename addons-path
0

Goto Terminal and enter the following command:

cd path/to/your/odoo-version/

./odoo-bin scaffold new_module /path/to/your/odoo-version/addons

Then goto /path/to/your/odoo-version/addons and refresh, you can see the "new_module" will be present.

Alex Butenko
  • 3,347
  • 3
  • 30
  • 51
Pravitha V
  • 3,140
  • 4
  • 26
  • 50
0

I suggest you for the first step to Git clone odoo. Create a directory/folder and you Git clone odoo on your directory/folder. After that run, Python odoo.py scaffold addons test123. Put or module on directory/folder addons for make sure, odoo can be read your module.

Idan
  • 4,819
  • 6
  • 33
  • 45
Stefani Johnsson
  • 175
  • 1
  • 4
  • 13
0

Ifyou are using odoo-10 or 11 then intead of using ./oe scaffold Academy ../my-modules use : ./odoo-bin scaffold new_module /path/to/your/odoo-version/addons

and if you are using odoo8 i.e. openerp8 then use odoo.py scaffold <module name> <where to put it>

but make sure you are on the correct location in the directory. Also find tutorial here in the link : https://www.odoo.com/documentation/8.0/howtos/backend.html

--Thanks

ABhay S

0

Here is my answer

cd path/to/odoo/odoo-server/

then

./odoo-bin scaffold new_module_name /path/to/custom/addons

now check /path/to/custom/addons, you will see new module where you can start adding you things.

0

First Change the directory where your odoo source: /opt/odoo

Then write this command: ./odoo-bin scaffold my_module_name /path-where-to-create

Example: ./odoo-bin scaffold odoo_module /Desktop/Repository

0

My file structure :-

Odoo |-- addons |-- debian |-- doc |-- setup |-- odoo-bin

To use the scaffold, you have to cd to (Odoo) folder then use this command

python3 odoo-bin scaffold name_of_your_module path_of_your_module

if i want to create a module named test at odoo/addons

i would just use the command :-

python3 odoo-bin scaffold test odoo/addons

Note:-

  • I haven't included every folder in the file structure, it was just to give you an idea
  • (python3) here depends on your python version
Mohmd labeeb
  • 136
  • 7
0

In Odoo v14 istalled on ubuntu 20.04 I use

odoo scaffold module_name /opt/extra-addons
-2

May be this code would help. Save it as moe.py or whatever you wanted.

from openerp.cli import scaffold

sf = scaffold.Scaffold()

#sf.run(["--help"])

sf.run (["--init","Academy","--model","academy","--controller","academy","--web","--theme"])

I'm still new to Python programming. If someone could improve the way to send arguments to the run() function, that would be great.

  • Could I have the reason for not being useful of this script? – sombatsombat Aug 25 '14 at 00:17
  • Just guessing... you posted this as an answer, but then you had to ask if it was correct or efficient. You probably should *not* have answered. Or, you probably should have vetted the code on [Code Review Stack Exchange](http://codereview.stackexchange.com/). Once you know the code is correct, then offer it as an answer here. – jww Aug 25 '14 at 00:20
  • I offered the best answer that I could (at that time) and it run correctly in my environment. I did not asking for the correction. So it should be an answer for someone asking or seeking for help (or may be just some hints). But yes, as I mentioned about my exerience of Python programming, this code is not efficient because the way I send arguments to the function. That's it. – sombatsombat Aug 25 '14 at 00:47
  • *"If someone could improve the way to send arguments to the run() function, that would be great"*. It sounds like to me the answer *is not* ready to be used. But again, I'm just speculating why you were down voted. It could have been because of the missing formatting, too (or some combination). – jww Aug 25 '14 at 00:50