Create Module

How To Create A New Module

Create a new module

This visual guide has been created to teach you how to make a Rapid Application Development with ERP5.

Agenda

  • How to design your application
  • How to create a module in ERP5
  • How to create objects in the new module
 

Application design for ERP5

Application design for ERP5

Each ERP5 instance is a website. This website can contain and use one or more modules such as a Blog (Blog Module), a News (News Module) a User Database (Persons Module).

The aim of this tutorial is to show you how easy it is to use the main options of ERP5 to develop a new web based application. Our test case will be the creation of a Forum to be used on a website.

Usually an advanced forum is very long to develop, because it depends of many other parts and is totally dynamic. But you will see that ERP5 will really improve your development time with easy to use functionalities.

The application design in ERP5 are object oriented, it uses the Python language and the Zope framework. If you are familiar with Python, you won't have problems to understand how to use ERP5. We will explain each part independently, step by step, and explain all the objects properties that we use.

Before you start, please read the supporting documents such as bt5-Module.Creation.Guidelines and understand rules which are required to develop and maintain ERP5 in a good manner. Those rules are very important if you wish to contribute and work with the community.

The Forum Module design

Forum module design

First we must think about the design of our forum. For that we need to create the module, the type and the content of the documents which we will used.

The Forum will be a simple module that you can consider like a folder. This folder will contains Threads which will themselves contain Posts.

Threads and Posts don't exists yet in our ERP5 instance, we will have to create them.

A Thread has a title, an owner, a creation date, a publication state and a number of posts and their replies, whereas a Post just contains a title, a content (a text area) and an owner.

Then we will configure how users can interacts with them.

Those objects can be easily accessible in our instance. For example if you wish to access a Thread you will use:

www.tiolive.com/INSTANCE_ID/forum_module/THREAD_ID

The same will happen if you wish to access a specific post, you will use:

www.tiolive.com/INSTANCEID/forum_module/THREAD_ID/POST_ID

In Python if you want to write a script for your application, you just need to write: context.getPortal().idOfTheModule.idOfTheThread.idOfThePost.post()

Requirements

Requirements

We assume that you have some base knowledge, logic and that we have an ERP5 instance where you can work on.

To follow this tutorial you need an ERP5 instance and a user with management rights. If you are working on TioLive you can access your instance through https://www.tiolive.com/INSTANCEID.

Before creating your first module, you must make sure you have all the required Business Templates installed on your instance. Business templates are ERP5 packages which can contain code and data.
By default, the instance provided to you should contain all needed business templates. If not, please look at:

To learn how to install them. When your instance is ready you can then start creating your forum!

Create a new Folder "erp5_forum"

Create a folder in portal_skins

Before creating a new Module, you have to create a new Folder in INSTANCE_ID/portal_skins/manage_main in order to put your module in it (called for example erp5_forum).

The manage_main interface allows modifying the ZODB directly. The ZODB is an object database used by Zope, and therefore ERP5. For more details, refer to the Zope tutorial.

Create your Module "Discussion Threads"

Create module

Now you can create a new module.

When you want to add a new functionality to ERP5, you must create a module. A module is the entry point for new features in ERP5. A module doesn't contain all your files and code. They will be placed in other locations. We will see later how to create a Business Template package to export all of our work.

In order to create the new module, you can use "My Favourites" menu. Depending on you level of access and of your location into your instance, you will see different options in the "My Favourites" menu. As a manager, you should have the possibility to "Create Module". Click on it in order to create a new module.

A module is a folder that contains all the documents we will use. The Module Creation form allows you to make two kinds of objects.

The first object kind is the module itself. Module ID will be the identity of your module. A folder will be created at the root level of the ERP5 instance in order to collect all documents within the module (this is why the ID of the module will be used in the URL to access it). The Module Portal Type is the human readable type of your module and the Module Title is the human readable title of your module. In our example, we create a new Module called Discussion Threads.

The second object kind is the Object Portal Type. It is the kind of object contained in your module. And the Object Title is the title given to the view of the object. In our example, this kind of object will be used for Threads in the Discussion Threads module.

The Module Creation form also allows you to choose a folder in /portal_skins call the Portal Skin Folder. This folder is used to store all your view elements, templates, and design elements (images, CSS, etc). As we have created the folder erp5_forum in the portal skins, you can now select it for your module creation.

You must be very careful with the names you will use for your new module, because they will be use later during all the development process. ERP5 uses a strict naming convention. If you respect it, you'll be able to access many features and have a development pace faster than ever. If you want to learn more, go to: GuidelinesForNamingConvention.

Add an object to your Module

Add an object to your Module

Once the module have been created, we already can add new objects in it. The Action bar is a fast way to access the options of an object.

There are two kinds of actions in an object. The actions which are associated by the user with the action tab and the ones that are automatically created depending of the properties of the object type itself, or any other object parameters (such as the contained types).

You will see later that an object can contain other objects. For each type of object that can be contained, ERP5 generates an “Add xxxx” action to add a new object of this type. In our example, at the creation of the Discussion Threads Module, we specified that the module could contain Discussion Thread Objects, this is why the Action: Add Discussion Thread is provided to you.

First access your module by selecting the module name in the Module bar. Then select Add Discussion Thread in the Action bar. After that, you will be in a transition window which asks you the Title. Fill it and save the changes, then you will find a new object created in the Discussion Threads Module.

Thank You

  • Nexedi SA
  • 147 Rue du Ballon
  • 59110 La Madeleine
  • France
  • +33629024425

For more information, please contact Jean-Paul, CEO of Nexedi (+33 629 02 44 25).