Wednesday, 28 August 2013

How to create a module in OpenERP ?

Creating a module in OpenERP is a very simple process. All modules are located in addons folder
To create a module go to Server-->  OpenERP-->  Addons then right click on addons and create a new folder with the name of your module..
         
 For instance create a demo_module.
Follow these simple steps:
  1. create  '__init.py__' file which helps to load the class.
  2. The '__openerp__.py' file which is needed to load the module
  3. The '.py' file in which you will be able to create class methods and all the programming.
  4. '.xml file' – In this you will create the view of the module, you can define fields menu and front view of module.
  5. The __init__.py file in this init file you have to import all .py file which is used in that particular module.
           

Example :
import demo
__openerp__.py file
This file is the descriptor file in which all the description about the module is written
1.    Determine the XML files during the initialization of the server, and also
2.    Determine the Dependencies of the created module.
This OpenERP file has the following values:
name: The  name of the module.

version: The version of the module in 2 digits (1.2 or 2.0).

description: The module description (text) including documentation on how to use your module.

author: The author of the module.

website: The website of the module.

license: The license of the module .

depends: List of modules on which this module depends. The base module must always be added in the dependencies because some necessary data for the views, reports,..are included in the base module.
init : List of .xml files to load when the server is launched with the "--init=module" argument. File paths must be relative to the directory where the module is. OpenERP XML File Format is detailed in this section.

data : List of .xml files to load when the server is launched with the "--update=module" launched. File paths must be relative to the directory where the module is. OpenERP XML File Format is detailed in this section.

demo : List of .xml files to provide demo data. File paths must be relative to the directory where the module is. OpenERP XML File Format is detailed in this section.

installable : True or False. Determines if the module is install able or not.

images : List of .png files to provide screenshots.

active : True or False (default: False). Determines the modules that are installed on the database creation.

test  : List of .yml files to provide YML tests.
The XML file :-
In this , we create the view of the module and we can also customize it.
There are 4 sections..
     1.  Creating the view i.e. form,tree,kanban and graph
  1. Defining the fields
  2. Creating the action for menu
  3. Creating the menu item.
How to install module on server:-

First open the terminal and go to the server directory and type the command.

 Syntax: . /openerp-server -u [module_name] -d [database name]

For Example: ./openerp-server -u  demo_module   -d demo
Then open the server on the browser using your local host and in the setting section, you can search the module in the search box and install it.

So have fun and start making your own modules.... 

Thanks

No comments:

Post a Comment