Lesson 1 the Products

Designing an App in ONE ERP must take into account at least two perspectives, one is the business problem and the other is the technical problem.

This lesson makes no exception so here are the two:

As a business problem

This App implements the management of a list of products with capabilites for searching and editing.

As a technical problem

This App implements a data model, search views, edit views, menus.

Contents

Design the data model

The first step in designing a ONE ERP app is constructing the data model. The data model consists of entities, properties and relationships between entities.

For the purpose of this lesson we will create an app that manages a list of products. Each product must have a name, a price, and a bar_code.

We will create one entity:

  1. product
    1. with the properties: 
      1. name of type: string
      2. price of type: decimal
      3. bar_code of type: string

Creating the entities

Click the Develop app, and then click on the Customization sets menu.

In page that opens click the Add button located above the list.

In the page that opens, under the Edit section, fill the Name of the customization set, in this case "products".

Select the Entities tab, click the Add button for each entity you want to add, in this case one time, and fill the entity name: product.

Select the Properties tab, click the Add button for each property you want to add, for each added property fill the Entity name field, the Property name field, and the Property type field. In this case you will fill:

Entity nameProperty nameProperty type
productnamestring
productpricedecimal
productbar_codestring

Click the Save button.

Publishing the entities

After the previous state the entities are saved as a draft, in order to be able to use them they need to be published as database tables. To publish the entities:

If you are not already in the Customization sets menu, click the Develop app, and then click on the Customization sets menu.

Select the row containing the "products" customization set.

Click the Publish button located above the list, next to the Add, Edit and Delete buttons.

Creating the views

The views help the user interact with the entities, in ONE ERP there are two main types of views:

  1. The search view to display the entities as a table, apply filters, navigate, add, edit, delete or apply custom actions to entities.
  2. The edit view to add or edit an entity.

For this example we will first create a search view for the products.

Products search view

Click the Develop app, and then click on the Search views menu.

In page that opens click the Add button located above the list.

In the page that opens, under the Search sectionfill the following fields with:

  1. Title (in ui) = Products

  2. List name (in url) = productSearch

  3. Key name (in results) = key

Select the Filters tab, click the Add button for each row, and enter the folowing:

TitleArgument nameInput typeOperatorProperty name
NamenameArgStringIsLikename

Select the Fetch tab, and enter the folowing fetch query:

FETCH product (key, name, price, bar_code)
FILTER AND (${nameArg})

Click the Execute button, located above the query, to test the query. The result should appear under the query and should contain only the column names and a empty result set.

Click the Save button.

Product edit view

Click the Develop app, and then click on the Edit views menu.

In page that opens click the Add button located above the list.

In the page that opens, under the Editor section, fill the following fields with:

  1. Name (in url) = .productEditor (note: if the name starts with dot (.) it means that your editor is a dialog otherwise is a page)
  2. Entity name = product
  3. Title new = New product
  4. Title edit = Product
  5. Title edit section = Edit product

Select the Inputs tab, click the Add button for each row, and enter the folowing:

TitleProperty nameInput type
NamenameString
PricepriceDecimal
Bar Codebar_codeString

Click the Save button.

Connecting the edit view to the search view

Click the Develop app, and then click on the Search views menu.

In page that opens locate the search view with the title Products and name productSearch, check it in the and click the Edit button located above the list.

In the page that opens, under the Search sectionfill the following field with:

  1. Edit view = .productEditor (should be selected from list, also notice the dot in front of the name)

Click the Save button.

Creating the App

Now that you have created the data model and the views you can use them to create the app.

Click the Develop app, and then click on the Menus menu.

In page that opens click the Add button located above the list.

In the page that opens, under the Edit menu section, fill the following fields with:

  1. Name = Products
  2. Node key = home
  3. Color = #009900
  4. Letters = P

Click the Add button located above the list and enter the following:

NameNode item key
Products#search\$productSearch

Click the Save button.

Click the Reload button on your browser, in the upper right corner of the screen you should see the P app.

Click the P app, and you should see the Products menu.

Now you should be able to search, add, edit and delete products.