How To Modularize The Location Selector

From InfiniteERP Wiki
Revision as of 12:12, 16 December 2021 by Wikiadmin (talk | contribs) (Created page with "{{RatingArticle}} {{Languages | Documentation_Style_Guide}} == Objective == The objective of this article is to show you how to modify and modularize the '''Location Selector'...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Objective

The objective of this article is to show you how to modify and modularize the Location Selector.

Recommended articles

Before reading this guide, it is necessary to have a proper understanding of Openbravo's Modularity concept and how to create and package a module,
as we take the knowledge from these articles as a given in this guide.

In case you are working with configuration scripts or templates on a regular basis, the following link to an article might be of interest to you, since it describes how to create a configuration script.

Execution Steps

The steps needed to change and modularize the Location Selector are as follows:

  1. Define your own Module and export it. The module folder will be then be generated, for example:
  2. modules/com.openbravo.support.locationexample/
    
  3. Create the source folder for the Module we just created previously. For our example it should look like this:
  4. src/com/openbravo/support/locationexample/info/
    
  5. Copy the original files of the Location Selector into the newly created folder. When copying the files, maintain the original file names. The original files are located at:
  6. src/org/openbravo/erpCommon/info/Location
    
  7. Modify the following files to make them part of your package:

    Location_Search_data.xsql:
    Change the defined package to: "com.openbravo.support.locationexample.info"
    

    Location.java:

    Change the package to: "com.openbravo.support.locationexample.info"
    
    Change the following mappings to use the new mappings:
    
    org/openbravo/erpCommon/info/Location_FS -> com/openbravo/support/locationexample/info/Location_FS
    org/openbravo/erpCommon/info/Location_F1 -> com/openbravo/support/locationexample/info/Location_F1
    org/openbravo/erpCommon/info/Location_F2 -> com/openbravo/support/locationexample/info/Location_F2
    

    After that you can apply all the changes you want to do. In our example we have just changed the labels for the fields.

    Bulbgraph.png   Note: There is a Trigger c_bpartner_location_trg that inserts the location name into the name field of the c_bpartner_location name after any changes. That name is created using the Function c_location_name.

    If you add new fields in the Location Selector and also want to use the information to compose the name, you will need to do the following:

    • Create your own Function based on c_location_name to compose the name that you want to save.
    • Create your own Trigger based on c_bpartner_location_trg to use that new function to save the name.
    • Deactivate the c_bpartner_location_trg Trigger and use your own one instead.

    To deactivate it, you have to delete it and then export the changes into a Template set In Development. At the top of the configScript.xml template you will see that there is a line that indicates that the trigger was removed (RemoveTriggerChange).

  1. Create a new search reference for the new files for your module and your own name. Define that new reference to use your own Java Class and your own mappings:
View larger
View larger
  1. Define a new template module and mark it as In Development. You can use the template we used to deactivate the Trigger: In the Tables and Columns window, find the column which you want to use with the Locator Selector we have created and change the "Reference Searchkey" combo to use this new reference. In the example we have done it in the C_Bpartner_location table, in the c_location_Id column.
  2. Compile the application with:
    ant smartbuild
  3. Restart tomcat and use the column to check that the new reference is working with the new changes.

Result

Following screenshot shows the results of our changes:

View larger