Develop your own ERP with ERP5 Business Templates

ERP5 Tutorial
www.erp5.org

version 0.9
Linux Solutions
February 2, 2005
Paris

Date	01/29/05
Version	0.1
Author	Kevin Deldycke
Contributors	Jean-Paul Smets
Translation Date	05/01/05
Translation Version	0.1
English Translators	Shrenik Bhura, Chris Purves, Yoshinori Okuji
Abstract	Introduction to the installation of Business Templates into ERP5 and to the development of new functionalities
Email	info@nexedi.com
Web	http://www.erp5.org
Rights	Copyright © 2004-2005 Nexedi
Licence	You have the permission to copy, distribute and/or modify this document according to the term of the GNU Free Documentation License, Version 1.1 as published by Free Software Foundation (http://www.gnu.org/copyleft/fdl.html) with the Front-Cover Texts being « ERP5 Tutorial www.erp5.org », with the Back-Cover Texts being « You are free to copy and modify this handbook, like all the free software and documentation products by the company Nexedi », and with the Invariant Section being « ERP5 Commercial Support ».

Contents

1. Introduction	4

2. ERP5: An ERP for All	6

2.1. ERP5 without installation : Using ERP5 Live CD	6

2.2. Traditional ERP5 Installation	6

2.3. Extending ERP5 with Business Templates	10

3. Creating a Business Template	16

3.1. The Structural Design of Data	16

3.2. Variation by categories	19

3.3. Integrating the data structure with ERP5	21

3.4. Fast Web Development with portal_classes	22

3.5. The structure of a Document class in ERP5	23

3.6. Creating a module in EPR5	27

3.7. Integrating the classes, data, menus and appearance: the tool portal_types	28

3.8. The user interface with ERP5Form	29

3.9. Python scripts for calculation	42

3.10. The reporting	49

3.11. The creation of the Business Template	58

3.12. A point on cataloguing	60

4. Conclusion	61

5. TODO	62

Introduction

This document is intended for developers who want to adapt ERP5 to their companies in order to meet their specific and unique needs.

With ERP5, it is not the company which conforms to the ERP logic any longer, but the ERP adapts itself to the culture, methods and practices of the company. ERP5 provides a framework and tools necessary for the achievement of this goal. This is most often accomplished by the creation and the modification of flexible ERP packages called «Business Templates».

This document will show you how to quickly install an ERP5 platform, and how to install and use Business Templates, by guiding you through the use of a simple module for payroll management. The second part of the document will describe all the techniques of ERP5 so that you can thereafter create your own Business Templates by yourself.

ERP5 Commercial Support

ERP5 is a free ERP, under the term of GPL, developed and published by the company Nexedi.

Nexedi coordinates a network of partners certified for the deployment of ERP5 solutions for enterprises. Nexedi and its partners assure, through the team of their engineers and their consultants, the assistance, the formation, and the transfer of competences necessary to the control of ERP5 in the field.

http://www.erp5.org/sections/documentation/evangelism/enterprise/

Tel.: +33 662 05 76 14

Mail: info@nexedi.com

ERP5: An ERP for All

ERP5 without installation : Using ERP5 Live CD

The easiest way to get started with ERP5 is to use the Live CD. The ERP5 Live CD saves your valuable time from wasting due to installation problems. It has been conceived as a production and development tool, not only intended for demonstration. It can be downloaded from: https://www.erp5.org/sections/download/erp5_livecd/view .

This illustrates its simplicity:

Insert a CD into a standard PC, and boot up from it. After a few minutes, it starts ERP5. You can then install Business Templates to use, configure, and extend.

Traditional ERP5 Installation

If the use of the Live CD is not suitable for you, it is possible to install ERP5 in a traditional way. It should take a few tens of minutes (if you use an operating system such as Mandriva Linux for which all packages and their dependences have been created) or a few days (if you use an operating system without ERP5 packages).

ERP5 needs the Zope application server on which it is based as well as a number of other Zope products. You also need to install MySQL-Max (a version of the most popular free database server which supports transactions). MySQL-Max is used as the search engine of Zope via the ZSQLCatalog product.

For a complete system, it is necessary to have:

A Zope server (and all its dependences related to Python) with the optimization developed by Nexedi, regarding meta-programming .

The Zope products BTreeFolder, Base18, CMF, CMFActivity, CMFCategory, CMFMailIn, CMFPhoto, CMFReportTool, ERP5, ERP5Catalog, ERP5Form, ERP5SyncML, ERP5Type, ExtFile, Formulator, Localizer, Photo, TranslationService, ZMailIn, ZMySQLDA and ZSQLCatalog.

MySQL-Max

To conclude this section, it is necessary to discuss packaging for your Linux distribution. You can also take the source and install Zope by a traditional ./configure, make, and make install. The Zope products can be easily and rapidly installed, since the archive files can be extracted in the Zope Products repository (generally /var/lib/zope/Products or /usr/lib/zope/lib/python/Products), and some extensions (zsqlbrain.py and InventoryBrain.py) can be added into the Extensions repository of Zope (generally /var/lib/zope/Extensions or /usr/lib/zope/lib/python/Extensions). You will find tutorials and documentation on the Internet for the installation and the total configuration of Zope without difficulties.

The happy users of Mandriva Linux can be satisfied with a simple urpmi ERP5, after having added the media main, contrib and nexedi with their package manager.

Once the package installations finish, use the administration console of Zope, zopectl, to change the default password of the administrator (the login by default being admin). The addition of a user can be made only if the Zope server is stopped. Note that the installation procedure above automatically may have started the server, you should thus stop it before proceeding:

[root@localhost /]# /etc/init.d/zope stop

Stopping zope : . daemon process stopped

[root@localhost /]# zopectl

program: /usr/bin/runzope

daemon manager not running

zopectl> help adduser

adduser <name> <password> -- add a Zope management user

zopectl> adduser admin admin

[root@localhost /]# /etc/init.d/mysql-max start

Starting MySQL Server [ OK ]

[root@localhost /]# zopectl

program: /usr/bin/runzope

daemon manager not running

zopectl> start

daemon process started, pid=7944

Let's check the operation of Zope by accessing the ZMI, the Zope management Web interface, where one will be authenticated with the password of the user admin which one has just added:

http://localhost:9080/manage

Illustration 1: The access to the ZMI requires an authentication

Illustration 2: ZMI, the Web interface for the management of Zope

As the Zope server is operational and accessible now, you will create an instance of ERP5 by selecting type ERP5 Site in the drop-down list in the top-right:

A page of properties is displayed in the ZMI, and you will fill it as on the screenshot:

The validation of this form leads to this screen if successful:

But it is frequent to see the following error appearing at this time:

Site Error

An error was encountered while publishing this resource.

Error Type: DatabaseError

Error Value: z0_catalog_object is not connected to a database

This error means simply that the MySQL-Max server is not started. A restarting of this server is enough so that all returns in the order.

You can now go to the title page of ERP5 via the URL:

http://localhost:9080/erp5/

Now that ERP5 is operational on your machine, you are ready to begin with it. We would, however, advise to update ERP5 products from the CVS of ERP5 , to benefit from the latest enchancements and bugfixes.

Warning: Although ERP5 is now installed and usable on your machine or your server, it is not advised to use it « just as it is » in a production. A fine configuration (a cluster, an activity system, etc.) is indeed necessary to obtain high performance, and a thought on the policy of data security is essential to protect the vital data for the company.

Extending ERP5 with Business Templates

The Business Templates are ERP5 packages, comparable to system packages (such as rpm and deb) in the Linux distributions. The purpose of the RPM is to simplify the installation of software within a system. The Business Templates have the same role as it takes charge of a clean and automated installation of an ERP5 component. From the point of view of a user, installing a Business Template is to add a major functionality to the ERP, by widening its capacities of the management of the company.

There are currently 8 Business Templates, each one dedicated to an aspect of the management of a company:

Trade : commercial management (purchases and sales, orders, delivery orders, invoices, inventory control)

PDM (Product Data Management) : management of the data produced (the definition of products, alternatives, categorization, nomenclatures, operational ranges, multi-media catalogues)

MRP (Manufacturing Resources Planning) : organization and production control (planning work orders for production)

CRM (Customer Relationship Management) : management of customer relations (databases of the organizations and people, commercial opportunities)

Accounting : accountancy (accounting transactions, financial reports)

HR (Human Resources) : management of human resources (payrolls, career management)

eCommerce : electronic trade (on-line store sales, affiliations)

CMS (Content Management System) : management of contents via Web (via Nuxeo- CPS )

Some of these Business Templates have reached a first stage of maturity (e.g. Accounting makes it possible today to enclose a financial year). The others are still in the course of integration.

Indeed, altough ERP5 is used today in production on important sites with a complete functional cover (e.g. nomenclatures, production management, calculation of needs, stock management, invoicing, etc.), the customers of ERP5 do not wish to finance the cost of integration in the form of generic Business Templates of the specific work which was carried out to adapt the ERP5 framework to their own needs. The work of integration of the Business Templates is thus carried out volunatrily by Nexedi. For this reason, all the functionalities of the ERP5 framework are not covered yet by the Business Templates available for downloading.

One of the modules designed first which uses the system of Business Templates is that of payroll management. This module makes it possible to manage a pay-book and to create payrolls.

It is this module which will be used as an example throughout the article. We now will detail the process of installation of this Business Template. This process requires an account with the right Manager.

First of all, open the module portal_templates with your browser by typing an URL http://localhost/erp5/portal_templates or http://localhost:9480/erp5/portal_templates, according to your configuration. You will be able to then reach the list of the Business Templates:

A more complete ERP5 system comprises many Business Templates:

Our objective is thus to pass from a practically empty list of Business Templates to a more complete list. To achieve this goal, it is enough to click on the button « Import/export » in the second bar of buttons starting from the top. This button resembles this:

After having clicked above, you arrive at the dialogue for importing a Business Template:

Use the menu « Exchange Select » to change the dialogue from « Import Business Template » to « Download Business Template » :

You then have to filll in the two fields, an identifier of the Business Template (e.g. erp5_accounting) and the URL of this Business Template (e.g. http://openbrick.org/cgi-bin/viewcvs.cgi/*checkout*/erp5_bt5/erp5_trade.bt5?rev=HEAD&content-type=text/plain), and then click on « Download Business Template ». The downloading will be automatically carried out (provided you have access to the Internet), and, in the case of success, you will see a message « Business Template Downloaded Successfully ».

You can then click on the Business Template which you have just downloaded. You will see a form:

Alternatively, you may download it separately to a local directory and thereafter « Imort Business Template ». Proceeding with the installation, choose « Install Business Template » from the drop-down menu « Action ». This will prompt you to validate this action:

Once you click on « Validate Workflow Action », you just have to wait for a while. This takes from a few seconds to a few minutes, depending on the contents of this Business Template.

You have just installed the ERP5 Business Template for accounting. This module is essential for the Business Template of payroll. Let's continue now with the payroll. The principle is the same. You just have to import a different Business Template by giving it an ID such as erp5_payroll and the URL for downloading http://openbrick.org/cgi-bin/viewcvs.cgi/*checkout*/erp5_bt5/erp5_payroll.bt5?rev=HEAD&content-type=text/plain

Here is an example of a payroll generated by this Business Template:

Illustration 3: Une feuille de paie générée par ERP5

This payroll will be created, based on a document available on the Community site erp5.org (http://www.erp5.org/workspaces/project/erp5_payroll/erp5_pay_sheet_for_n).<<This document needs to be verified for completeness and concurrency with the current state of erp5 as several links are missing and certain guiding steps given do not work as shown>> This English document intended for the beginners explains the procedures to be followed in the end. It will help you in the use of the payroll module. Now that you know the principle of the Business Templates from the point of view of users, you can start at the heart of this article: the creation of a Business Template.

Creating a Business Template

The objective of the second part of this article is to offer an overall picture of the ERP5 development platform to developers. The payroll module will be rebuilt in the end. This will give us the opportunity to show the user-friendliness and the power of ERP5 for the rapid creation of functional modules, and also the technological approach and the concepts which are the core of ERP5.

The Structural Design of Data

All ERP5 objects derive from 5 fundamental classes:

This ideal model of EPR5 has already been the subject of a scientific publication which shall be interesting to consult to understand the motivation which lies behind each key concept of ERP5.

Here is the descriptions of the 5 fundamental classes:

Resource

A resource describes an abstract resource in a business process, such as an individual's skill, a currency, a raw material, or a product.

Node

Nodes can receive and send resources. They can relate to physical entities (such as a workshop that receives raw material, processes it, and sends it), or abstract entities (such as a bank account that can receive money). Stocks are a type of node. Metanodes are nodes that contain other nodes. For instance, a company is a metanode, and a project is both a resource and a node.

Movement

This class describes the movement of resources between two nodes at a given time and for a given duration. For example, a movement might send raw material from a stock to a workshop; another movement might send money from one account to another.

Path

A path defines a way for a node to access a resource it might need. Prices and commercial profiles can attach to a path to define the default price for a given resource produred at a given maker. A path can also define how a workshop obtains its resource from a stock. A path has a start and end date, and can represent the assignment of an individual to a temporary project.

Item

A physical instance of a resource is an item. A movement can expand into a series of traceable movements through items. Items also define how resources ship (such as by parcel or by listing the serial numbers of items in each container).

By analyzing a traditional French payroll, we chose to create 4 types of objects:

PaySheetTransaction

PaySheetTransactionLine

PaySheetLine

PaySheetCell

Here is a diagram of classes which gives the hierarchy and the inheritance making it possible to connect the base classes of ERP5 with our 4 new types of objects:

The structure of data of the payrolls is based on the model of invoicing (Invoice). This is described by 3 classes: Invoice, InvoiceLine and InvoiceCell. These three classes allow for depicting an invoice (Invoice) in lines of invoicing via InvoiceLine (a line of invoice by invoiced product), which can be decomposed according to variations of the same invoiced product. InvoiceCell thus makes it possible, for example, to detail the invoicing of a quantity of four products A, of three products A with the color blue, and of one product A with the color green.

As the diagram shows it, the invoices specialize the representation of the delivery (Delivery) which implements the origin of the structure Line/Cell.

The cells (Cell) are the visible part of the concept of variation which ERP5 offers. This concept makes it possible to represent variations of the same resource, like the color, the size, or the speed. This makes it possible to define several configurations of the same product.

The advantage of this system lies in the possibility of very deeply configuring the ERP5 while keeping the benefit of a generic management of data, according to a standard structure. We will detail the concept of variation a little further in this article.

Here is a detailed information on our various classes:

PaySheetTransaction

The payroll is represented by an object of the type PaySheetTransaction.

This class derives from the basic class Folder via Invoice. We chose this inheritance, because the purpose of PaySheetTransaction is to simply put objects related to a payroll in a single place. This is why PaySheetTransaction does not have any ancestor class from the 5 basic classes of ERP5. Folder is, to some extent, an "utility class" which allows us to reduce the entropy of the system.

Although PaySheetTransaction is of the type Folder and it behaves similarly with an invoice (Invoice), some behaviors are specific to a payroll. So we had to create a new class. These particular behaviors take into account the concept of employer and employee as well as other data specific to the payroll (the date of a payment, a gross salary).

PaySheetLine

As the diagram indicates it, each PaySheetTransaction can contain a number of PaySheetLine which are the representation of various contributions<<deductions/allowances>> withdrawn on<<from>> a gross salary. For each contribution, there is one and only one PaySheetLine.

PaySheetCell

PaySheetLine contains PaySheetCell, which may represent and detail the amounts of PaySheetLine. The variation system will make it possible to distinguish the employer's and employee's share from a given social security contribution, and to preserve a trace of the calculation method of the amounts.

For a given contribution, the total amount of one part (of a salary or of an employer's) may be the result of a scientific calculation utilizing one or more rates, associated with a tax base respectively (gross salary, ceiling salary, sliced salary A/B/C, and so on). The calculation of the payrolls is not obvious, especially as the legislation changes every day.

The variation reduces the amount of code in this case, because it is possible to tackle all the complications induced by the legislation of each country with a small piece of code.

PaySheetTransactionLine

PaySheetTransactionLine is the countable representation of the payroll. We have decided to distinguish PaySheetLine from PaySheetTransactionLine, because the representation of the payroll in an accounting logic gathers certain amounts, and this makes it impossible for fine reporting on the pay.

We thus have within PaySheetTransaction two sets:

The data of the couple of PaySheetLine/PaySheetCell : a set of basic data with which we can display the details of the payroll, and handle the figures in all the directions.

The data of the type PaySheetTransactionLine, which represents the accounting lines of the payroll.

Now that we have a coherent data model, we will implement it in ERP5.

Variation by categories

The objects of the type Category are used in ERP5 for classification. For example, a document can have an attribute color. Instead of letting the user enter a free value, one will prefer to allot a category to the object via a text field for the attribute color. One will thus create the categories color/blue, color/green, and color/red via the ZMI:

The categories can contain subcategories. For example, to describe the geographical areas:

region/europe

region/europe/west/

region/europe/west/france

region/europe/west/germany

region/europe/south/spain

region/americas

region/americas/north

region/americas/north/us

region/americas/south

region/asia

In this example, the base category is region.

The categories have other advantages, such as automatic cataloguing. This mechanism makes it possible the use of SQL queries to select the ZODB objects, according to the value of the category (refer to the section « The point on cataloguing »).

It is possible to create virtual classifications based on existing documents or categories. For example, if a document is accessible with the path organisation/nexedi, and there is a base category client, the tool portal_categories allows the creation of the virtual category client/organisation/nexedi. This allows for representing the relation: « the client of such an object is the organisation Nexedi ».

The concept of the virtualisation of categories avoids the duplication of information by offering mechanisms equivalent to a base of relational data.

Integrating the data structure with ERP5

We will add all the classes defined in the previous section into ERP5. ERP5 has clean mechanisms to define new classes of objects, which permits it to deal with dynamic and automated creation of methods. All we have to do with the new classes is thus describe them. ERP5 will take care of the remainder, like the dynamic creation of the « setter » and « getter ».

The classes are defined in a file under Document of the Zope/ERP5 directory in Python. We will create a new class PaySheetTransaction, and, to avoid keying again all the code, make a copy of the file Invoice.py:

[root@localhost /]# cd /usr/lib/zope/lib/python/Products/ERP5/Document/

[root@localhost Document]# cp Invoice.py \

/var/lib/zope/Document/PaySheetTransaction.py

[root@localhost Document]# cd /var/lib/zope/Document/

[root@localhost Document]# vi PaySheetTransaction.py

(…)

[root@localhost Document]# chown zope:zope PaySheetTransaction.py

[root@localhost Document]# chmod 0644 PaySheetTransaction.py

Here is what the file PaySheetTransaction.py looks like after editing:<<the file under /var/lib/zope/Products/ERP5/Document is not consistent with the one below>>

from AccessControl import ClassSecurityInfo

from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface

<from Products.ERP5Type.XMLObject import XMLObject instead of> from Products.ERP5.Document.Invoice import Invoice

class PaySheetTransaction(XMLObject instead of Invoice):

"""

A paysheet will store data about the salary of an employee

"""

meta_type = 'ERP5 Pay Sheet Transaction'

portal_type = 'Pay Sheet Transaction'

add_permission = Permissions.AddPortalContent

isPortalContent = 1

isRADContent = 1

# Declarative security

security = ClassSecurityInfo()

security.declareObjectProtected(Permissions.View)

# Default Properties

property_sheets = ( PropertySheet.Base

, PropertySheet.SimpleItem

, PropertySheet.CategoryCore

, PropertySheet.Task

, PropertySheet.Arrow

, PropertySheet.Delivery

, PropertySheet.Movement

, PropertySheet.Amount

, PropertySheet.XMLObject

, PropertySheet.PaySheetTransaction

)

# Declarative Interface

__implements__ = ( )

Fast Web Development with portal_classes

It is possible to accomplish all the operations of creation of classes or editing of the code via the Web interface of ERP5, thanks to the tool portal_classes:

The editing of python code of an ERP5 class also makes it possible to reload the only modified code without starting Zope again, and to gain in productivity.

The tool portal_classes is very useful in a prototyping phase or for fast development. It also facilitates ERP5 training. It is, however, not advised to activate it on a system in production, because it involves high security risk. Also, it is deactivated by default in ERP5 Live CD or ERP5 packages for Mandriva Linux. To activate it, it is thus necessary to create an empty file ALLOW_CLASS_TOOL in the ERP5Type product repository

[root@localhost /]# cd /var/lib/zope/Products/ERP5Type/

[root@localhost ERP5Type]# touch ALLOW_CLASS_TOOL

[root@localhost ERP5Type]# chown zope:zope ALLOW_CLASS_TOOL

[root@localhost ERP5Type]# chmod 0644 ALLOW_CLASS_TOOL

Thereafter, add an ERP5Type Tool from the drop-down under /erp5 in the ZMI.

The structure of a Document class in ERP5

The files of the type Document generally look the same, and the values specific to our new class would be guessed easily.

Each file of the Zope/ERP5 instance uses PropertySheet which contains Python scripts similar to those which one finds in the directory PropertySheet of the product ERP5. These scripts with the descriptive names may define attributes of classes, and, by extension, the structure of data of ERP5. The classes usually refer to them via the list property_sheets, as you can see it in the preceeding Python code.

To allow each payroll to store a gross salary, we have to refer to the property sheet PaySheetTransaction which will contain the definition of the attribute gross_salary of the type float. We should now create it:

[root@localhost /]# cd /var/lib/zope/PropertySheet/

[root@localhost PropertySheet]# vi PaySheetTransaction.py

(…)

[root@localhost PropertySheet]# chown zope:zope PaySheetTransaction.py

[root@localhost PropertySheet]# chmod 0644 PaySheetTransaction.py

Here is the contents of the property sheet PaySheetTransaction.py:

class PaySheetTransaction:

"""

Properties for PaySheet Transaction objects

"""

_properties = (

{ 'id' : 'gross_salary'

, 'description' : 'This variable contain the gross salary of the paysheet'

, 'type' : 'float'

, 'mode' : 'w'

},

)

_categories = ( 'source'

, 'destination'

, 'source_section'

, 'destination_section'

)

The syntax is rather intuitive, because all the attributes are declared with a list of Python dictionaries in the variable _properties. Pay attention to the immutable lists (tuple) of one element in Python, and do not forget the comma before the ending bracket.

[kevin@localhost Products]$ python

Python 2.3.3 (#2, Feb 17 2004, 11:45:40)

[GCC 3.3.2 (Mandrake Linux 10.0 3.3.2-6mdk)] on linux2

Type "help", "copyright", "credits" or "license" for more information.

>>> (5)

5

>>> (5,)

(5,)

>>> (5,10)

(5, 10)

>>>

Thus (5) is interpreted as an integer 5, and (5,) as an immutabe list containing only one element equal to 5.

The list _categories contains the list of virtual categories. We will use those to create a relation among a payroll, an employer, and an employee. The relation source_section will refer to an employer (who is the organization or the company which generates a payroll), and the relation destination_section will refer to an employee (the person for whom a payroll is generated).

If we need to define more complex attributes later, we will begin with the PropertySheets preexistent in the ERP5 product. This method is valid for all the approaches in this article: since the source code is open, it should be reused by taking existing things to build new things gradually. It is even an obligation to contribute to the code of ERP5: two similar properties must, by principle, have the same name in ERP5.

Now that our new class is built, it is necessary either to reload its code (with portal_classes on the class of PropertySheet then on the class of Document), or to restart the Zope server, so that it can take them into account. Once this is done, the server will be available, and you will be able to reach the ZMI:

[root@localhost kevin]# zopectl

program: /usr/bin/runzope

program running; pid=4450

zopectl> restart

. daemon process restarted, pid=4773

zopectl> logtail

------

2004-05-12T18:50:03 INFO(0) Z2 Caught signal SIGTERM

------

2004-05-12T18:50:03 INFO(0) Z2 Shutting down fast

------

2004-05-12T18:50:03 INFO(0) ZServer closing HTTP to new connections

------

2004-05-12T18:50:03 INFO(0) ZServer closing FTP to new connections

------

2004-05-12T18:50:03 INFO(0) Zope Shutting down with exit code 0

()

------

2004-05-12T18:50:42 INFO(0) Zope Ready to handle requests

zopectl>

It is possible that, at the time of the restarting, Zope stops, and obstinately refuses to start. It is also possible to observe a strange behavior of Zope: looping stopping and starting of the server every 10 seconds.

The causes of this blocking are mostly bad permissions on scripts or bad ownership on the files which you have just created. A series of chmod and chown will fix this problem.

If the problem persists in spite of these corrections, zopectl integrates a command debug, which stops the server and starts it by posting the log of starting and a report of the execution (traceback) in case of an error.

For example:

[root@localhost kevin]# zopectl

program: /usr/bin/runzope

daemon manager not running

zopectl> debug

Starting debugger (the name "app" is bound to the top-level Zope object)

(…)

Traceback (most recent call last):

File "<string>", line 1, in ?

File "/usr/lib/python2.3/site-packages/PIL/__init__.py", line 50, in app

File "/usr/lib/python2.3/site-packages/PIL/__init__.py", line 46, in startup

File "/usr/lib/zope/./build/build-base/python-2.3/build-lib/Zope/App/startup.py", line 45, in startup

File "/usr/lib/zope/./build/build-base/python-2.3/build-lib/OFS/Application.py", line 631, in import_products

File "/usr/lib/zope/./build/build-base/python-2.3/build-lib/OFS/Application.py", line 654, in import_product

File "/usr/lib/zope/lib/python/Products/ERP5/__init__.py", line 50, in ?

from Tool import Category, CategoryTool, SimulationTool, RuleTool, IdTool, TemplateTool, TestTool

File "/usr/lib/zope/lib/python/Products/ERP5/Tool/Category.py", line 35, in ?

from Products.ERP5.Document.MetaNode import MetaNode

File "/usr/lib/zope/lib/python/Products/ERP5/Document/__init__.py", line 3145, in ?

import PaySheetTransaction as ERP5PaySheetTransaction

File "/usr/lib/zope/lib/python/Products/ERP5/Document/PaySheetTransaction.py", line 62

__implements__ = ( )

^

SyntaxError: invalid syntax

>>>

The traceback shows that there is an invalid syntax error in line 62 of the file / usr/lib/zope/lib/python/Products/ERP5/Document/PaySheetTransaction.py. While publishing, it says that the developer forgot to close the list property_sheets with a bracket. Once this small mistake is corrected, the Zope server will start fine.

Caution: to use the debug command, one should not forget to turn on the option debug-mode in the file /etc/zope.conf. It is not surprising to have to use debug 30 times per day when one is a beginner and does not undestand the syntax of Python, or when one works on the CVS of an ERP5 project in a team and conflicts emerge.

Based on the same principle, we built the new classes PaySheetTransactionLine, PaySheetLine and PaySheetCell. If you are interested, take a look at the definitions of the classes:

[root@localhost /]# cd /usr/lib/zope/lib/python/Products/ERP5/Document/

[root@localhost Document]# vi PaySheetTransactionLine.py

[root@localhost Document]# vi PaySheetLine.py

[root@localhost Document]# vi PaySheetCell.py

You might have noticed that the code of the payroll module is sometimes located in the directory /usr/lib/zope/lib/python/Products/ERP5/Document/ and sometimes in the directory /var/lib/zope/Document. An explanation is essential. The directory / var/lib/zope/Document is designed for the rapid development of code of extension to the ERP5 framework. So It is useful to start to work in this directory when one conceives a new set of classes for a customer or a future extension of ERP5. If this set of classes seems sufficiently generic, and likely to correspond to a universal function of an ERP, it would be better to integrate it into the project ERP5, in order to share it with the whole community. This is the case with the payroll. On the other hand, if this set of classes is related to a trade or the specific needs for a company, there is no reason to integrate it into the core of ERP5.

As the payroll module is a part of the core of ERP5, it often refers to files located in the directory Document of ERP5. However, for the needs of the tutorial, we created all the new classes in the Zope/ERP5 directory, i.e. generally /var/lib/zope.

Creating a module in EPR5

During the introduction of this section, we mixed up the Business Templates with the modules of ERP5. We now make the difference, and more precisely describe the role of a module, within the context of ERP5, then create one.

A module is simply a place in the user interface of ERP5 to gather the functionalities suitable for an aspect of the management of a company. A Business Template contains all scripts and objects which realizes a module function.

The fast creation of a new module can be carried out by going to the URL:

http://localhost:9480/erp5/ERP5Site_viewCreateModuleDialog<This link does not work..instead managed to get http://localhost/erp5/ERP5Site_viewCreateModule working but the screen in different with only 3 parameters asked for 'Id', 'Title', 'Portal Type'>

where appears the following dialogue:

This dialogue consists of 6 parameters:

Module ID : The ID of the folder (Folder) created in the root of the ERP5 site which shall contain all the payrolls.

Module Portal Type : The name of the document type which will be created to contain all the payrolls.

Module Title : The title which will appear in the menu of modules for the payroll module.

Object Portal Type : The name of the document type which will be created to define a payroll.

Object Title : The title which will appear for each payroll by default.

Portal Skins Folder : The folder in which the forms will be created by default.

On clicking on « Create New Module », all the document types are automatically created, and the menu is updated. An « empty » payroll module is created. Now the question is how to configure it. <<This section does not work as mentioned above. Pls review this completely.>>

Integrating the classes, data, menus and appearance: the tool portal_types

ERP5 is constructed upon the architecture Zope/CMF. One of the characteristics of the CMF is the concept of tool placed at the root of a portal, and designed to provide various services: translation of formats of documents, management of menus associated with a document, internationalization, synchronization, etc.

The tool portal_types can create generic types of documents on the basis of our classes defined in the preceding part, and can associate menus to them as well as elements of appearance. We will make the distinction thereafter between portal_types (the tool) and portal types (types of documents defined by the tool portal_types).

The contents of the tool portal_types corresponds to the modules and the document types available in the ERP5 instance.

In short, all our portal types PaySheet* are images of our classes defined by our Python scripts in Zope.

The reality is more subtle because we can have two different portal types which are based on the same class. This is because their fundamental role is to create document types. For example, from the same class WrittenDocument, we can create two different portal types: Article and PressRelease. Both are described by the same structure of data and the same properties. The interest in creating two types of documents is that we can apply a different workflow or a customised appearance of a page to each type.

The source code of this optimization is available from the URL http://www.nexedi.org/static/Mandrake/10.1/SRPMS/zope-2.7.2rc1-1nxd.src.rpm

http://www.nexedi.org/static/Mandrake/10.1/RPMS

http://cvs.erp5.org – also see the script update_cvs.sh in /var/lib/zope/ to automate the updates

http://www.cps-project.org/

http://www.computer.org/itpro/cover_stories/smets.htm

Page 29

Page 29 / 29

2004-03-22T23:23:13

Jean-Paul Smets