View source | Discuss this page | Page history | Printable version   
Toolbox
Main Page
Upload file
What links here
Recent changes
Help

PDF Books
Add page
Show collection (0 pages)
Collections help

Search

How to Create a Window

Contents

Objective

The objective of this how-to is to show how you can create a new window from scratch. The how-to builds on top of two previous how-to's which explained How to create a module and How to create a table.

As a reminder the scenario this is based on:

Imagine we are developing an HR module and we need a window that will enable the user to input salaries of employees. We also need to track the employee's salary so history records need to be preserved. Each salary record needs to have a Valid From Date field that indicates when a particular salary came into being. The record belonging to a particular employee with the latest Valid From Date is the salary that is valid today. Note that employees are already inside the system contained in the C_BPARTNER database table and indicated by the C_BPARTNER.ISMEPLOYEE column. Therefore, we only need to create a database table that will hold the actual salaries.

Module & Table

As mentioned in the objective this tutorial is based on two previous tutorials and assumes that the following objectives have been already completed:

Creating the New Window

Using the System Administrator role navigate to Application Dictionary || Windows, Tabs and Fields. Create a new record as indicated by the screenshot below:


CreateWindow6 30.png

Main fields of this window are (for more information see the AD_Window table description):


Save this record and move to Tab tab. Create a new record as shown below, creating the first tab to show the employee information:


CreateWindow7 30.png

Main fields of this window are (for more information see the AD_Tab table description):

Save this record and then click the Copy Tab Fields button to copy fields from the existing main tab of the Business Partner window into our new one. Select the Business Partner-Business Partner Tab - Window combination and confirm the dialog with OK.


CreateWindow7.5 30.png


Move to Field tab to see all the created fields.


CreateWindow8 30.png


If required, changes to these fields could be made or new ones could be added manually. For not header tabs, it is very important not to remove the field that point the to the ID field of its parent tab, as it would made not possible to create records in this tab using the grid view. For more information see the AD_Field table description. However, in our case we are happy with the way they are.

Now, go back to Tab tab and create a new record that will represent the child tab of the Employee tab where salaries will be managed:


CreateWindow9 30.png


Most importantly, make sure you select:

For more information see the AD_Tab table description.

By clicking and confirming the Create Fields dialog, the application will automatically insert the columns of the selected table into the fields tab of the Salary one.


To arrange the columns according to common look and feel of other windows we now change a view field properties as can be seen in following screenshot.


CreateWindow10 30.png


For Openbravo to create links (labels that appear blue) to table elements, the system needs to know which window represents the table where a certain element resides. In our case, the Employee Salary window is used to manage the content of the HT_Salary database table. Hence, all salary records need to be shown within that window. To indicate that go to the Application Dictionary || Tables and Columns window, find our HT_Salary table and set the Window as indicated below:


CreateWindow11 30.png

Creating the Menu Item

A menu item is required for the user to be able to call up the new window we developed. Using the System Administrator role navigate to General Setup || Application || Menu and create a new record:


CreateWindow12 30.png


Main fields of this window are (for more information see the AD_Menu table description):

Save this record then click on Tree icon CreateWindow13 30.png.

Here you can drag and drop the new Employee Salary menu item to any of the other menu groups.


CreateWindow14 30.png

Compiling the Application with the New Window

Finally, the application needs to be recompiled in order to generate the new window's code and deploy it to Tomcat. If using Eclipse, use the eclipse.compile ant task, choose eclipse.compile as Ant Configuration and enter '"Employee Salary"' into the dialog that pops up. If manually compiling Openbravo, use the ant compile.development -Dtab="Employee Salary"

Important note: once the compilation has finished, restart Apache Tomcat server. In Windows, it is best to stop the Tomcat before running the build task and the start it again afterwards since Windows locks certain files the the compile.development build task might not be able to copy over.

See more on Build Tasks.

The Result

Using the F&B International Group Admin role, select the link to the new window from the menu. Notice the new window and the two tabs hierarchically positioned one above another (one Employe can have one or more salary records):


CreateWindow15 30.png


By double clicking Juan Lopez , details of this employee appear, however in a read-only mode (notice all fields are gray).

By clicking 'New in form' while having the Salary tab in focus a salary record can be created for this employee.


CreateWindow16 30.png


You have now successfully created your own new window and seen how it came to life within Openbravo ERP. Congratulations!

Retrieved from "http://wiki.openbravo.com/wiki/How_to_Create_a_Window"

This page has been accessed 34,271 times. This page was last modified on 1 August 2016, at 12:35. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.