Beautiful Code [252]
As the name indicates, ERP5 therefore defines five abstract concepts that lay the basis for representing business processes:
Resource
Describes a resource necessary to realize a business process, such as individual skills, products, machines, and so on.
Node
A business entity that receives and sends resources. It can be related to a physical entity (such as industrial facilities) or an abstract one (such as a bank account). Metanodes are nodes containing other nodes, such as companies.
Path
Describes how a node accesses resources it needs from another node. For instance, a path may be a trade procedure that defines how a client obtains a product from a supplier.
Movement
Describes a movement of resources among nodes at a given moment and for a given period of time. For example, one such movement can be the shipping of raw material from the warehouse to the factory. Movements are realizations of Paths.
Item
A unique instance of a resource. For instance, a CD driver is a resource for assembling a computer, while the CD driver Part Number 23E982 is an item.
These, along with some other supporting concepts like Order and Delivery, form the ERP5 Unified Business Model (UBM). It is possible to implement a new business process by combining and extending the five concepts, as we will see in this chapter. The relationships among the five core concepts are shown in Figure 21-1. A Path is related to a source node that sends a Resource to a destination node. A Movement is similar, representing a movement of an item that is described by a Resource from a source node to a destination node.
Figure 21-1. ERP5 core classes
ERP5: Designing for Maximum Adaptability > The Underlying Zope Platform
21.3. The Underlying Zope Platform
To understand why ERP5 is said to be document-driven, it is necessary first to understand how Zope and its Content Management Framework (CMF) work. Zope was originally developed as a web content management environment that provides a series of services to manage the life cycle of web documents. With time, people started to note that it can be also used to implement any kind of web-based application.
In keeping with Zope's web content focus, its CMF is a framework that aims to speed the development of applications based on content types. It provides a series of services associated to these types, such as workflow, searching, security, design, and testing. From Zope, CMF inherits access to the ZODB (Zope Object Database), which provides transactions and undo functionality.
CMF implements the structural part of applications through CMF Types, maintained by the portal_types service, which is in turn a kind of registry tool for the recognized types of a given portal. The visible part of a portal type is a document that represents it. To implement behavior, portal types have actions associated with them, composing a workflow, which in turn is the implementation of a business process. An action on a document changes its state and is implemented by a Python script that realizes some business logic; for instance, calculating the total cost of an order. Given this framework, when developing an application in ERP5, we have to think in terms of documents that hold business process data and whose life cycles are kept by workflows, which implement the business process behavior.
To take advantage of the CMF structure, ERP5 code is divided into a four-level architecture that implements a chain of concept transformations, with configuration tasks at the highest level.
The first level comprises the five conceptual core classes. They have no code, only a skeleton, for the sake of simple documentation:
class Movement:
"""
Movement of a quantity of a resource in a given variation
from a source to a destination.
"""
At the second level is the real core classes' implementation in Python. But here, they are still abstract classes. Still, there is already some Zope stuff in the classes,