ADempiere 3.6 Cookbook
上QQ阅读APP看书,第一时间看更新

Creating a window with multiple tabs

It is pretty common to logically relate the information using tabs. This recipe describes the steps to add multiple tabs in a window. So far, we have our basic MOM window. Now, we will break it into multiple tabs:

  • The Participants detail is moved to a new tab—Participants
  • The Discussion detail is refined and we are going to capture the following information as part of every discussion item:
    • Item number
    • Discussion description
    • Actioned by
    • Status

      This is also moved to a new tab—Discussion Detail

Getting ready

Connect to the database adempiere360 using adempiere as a user using your favorite PostgreSQL client (for example, phpPgAdmin or pgAdmin III or command based psql).

How to do it...

  1. Delete the records from the c_mom table.
  2. Delete the menu—Minutes Of Meeting.
  3. Related to MOM, delete the following from the Window, Tab, and Field windows, as per the order mentioned:
    • Field(s)
    • Tab
    • Window
  4. Related to MOM, delete the following from the Table and Column windows, as per the order mentioned:
    • Columns
    • Table
  5. Drop the adempiere.c_mom table by running the following SQL:
    DROP TABLE adempiere.c_mom;
    
  6. Apply the following SQL to your adempiere schema:
    CREATE TABLE adempiere.c_mom (
    c_mom_id numeric(10,0) NOT NULL,
    ad_client_id numeric(10,0) NOT NULL,
    ad_org_id numeric(10,0) NOT NULL,
    isactive character(1) DEFAULT 'Y'::bpchar NOT NULL,
    created timestamp without time zone DEFAULT now() NOT NULL,
    createdby numeric(10,0) NOT NULL,
    updated timestamp without time zone DEFAULT now() NOT NULL,
    updatedby numeric(10,0) NOT NULL,
    value character varying(30) NOT NULL,
    name character varying(255) NOT NULL,
    start_date date NOT NULL,
    start_time timestamp without time zone NOT NULL,
    end_time timestamp without time zone NOT NULL,
    chairperson character varying(80),
    agenda character varying(4000),
    CONSTRAINT c_mom_pkey PRIMARY KEY (c_mom_id)
    );
    CREATE TABLE adempiere.c_mom_discussionline (
    c_mom_discussionline_id numeric(10,0) NOT NULL,
    c_mom_id numeric(10,0) NOT NULL,
    ad_client_id numeric(10,0) NOT NULL,
    ad_org_id numeric(10,0) NOT NULL,
    isactive character(1) DEFAULT 'Y'::bpchar NOT NULL,
    created timestamp without time zone DEFAULT now() NOT NULL,
    createdby numeric(10,0) NOT NULL,
    updated timestamp without time zone DEFAULT now() NOT NULL,
    updatedby numeric(10,0) NOT NULL,
    item_nbr numeric (10,0) NOT NULL,
    discussion_desc character varying(2000),
    actionedby character varying(80) NOT NULL,
    status character varying(80),
    CONSTRAINT cmom_cdiscussionline FOREIGN KEY (c_mom_id)
    REFERENCES adempiere.c_mom (c_mom_id) MATCH SIMPLE
    ON UPDATE NO ACTION ON DELETE NO ACTION DEFERRABLE INITIALLY DEFERRED
    );
    CREATE TABLE adempiere.c_mom_participantsline (
    c_mom_participantsline_id numeric(10,0) NOT NULL,
    c_mom_id numeric(10,0) NOT NULL,
    ad_client_id numeric(10,0) NOT NULL,
    ad_org_id numeric(10,0) NOT NULL,
    created timestamp without time zone DEFAULT now() NOT NULL,
    createdby numeric(10,0) NOT NULL,
    updated timestamp without time zone DEFAULT now() NOT NULL,
    updatedby numeric(10,0) NOT NULL,
    participant character varying(80),
    company character varying(80) NOT NULL,
    CONSTRAINT cmom_cparticipantsline FOREIGN KEY (c_mom_id)
    REFERENCES adempiere.c_mom (c_mom_id) MATCH SIMPLE
    ON UPDATE NO ACTION ON DELETE NO ACTION DEFERRABLE INITIALLY DEFERRED
    );
    
  7. c_mom: Represents the basic MOM detail

    c_mom_discussionline: Represents each MOM discussion detail

    c_mom_participantsline: Represents each MOM participant detail

  8. Follow the steps mentioned in the Create a new window recipe to create the tables and their columns. The following screenshot shows the list of tables after the completion of the steps:
    How to do it...
  9. Also, create a Minutes Of Meeting window with the MOM tab, as per the steps mentioned in the Create a new window recipe. Similarly, add the Participants and Discussion Detail tabs using the c_mom_participantsline and c_mom_discussionline tables, respectively, as shown in the following screenshot:
    How to do it...
  10. The Sequence field on the Tab screen determines the tab sequence. A tab with the least value of Sequence appears as the first tab and the one with the largest value appears as the last tab.
  11. Select the Participants tab and switch to the single row view. The important fields are:
    • Table: Select the participants table
    • Link Column: Select the MOM ID on the c_mom table
    • Tab Level: 1
    How to do it...
    • ADempiere uses Tab Level to indent the tab on a window and also, internally, uses it to create SQL joins to fetch the related records. The main tab has the tab level as 0, by default. Moreover, a tab with level 1' becomes the child of the main tab and is indented accordingly. For example, in the previous image, the tab Access has a tab level of the main tab—Window. Tabs with the same tab level are siblings or peers. For example, in the previous image, the Access and Tab tabs are at the same tab level.
  12. Review the Field Sequence tab and make the required changes to the sequence, as shown in the following screenshot:
    How to do it...
  13. Select the Discussion Detail tab and switch to the single row view. The important fields are:
    • Table: Select the discussion line item table
    • Link Column: Select the MOM ID on the c_mom table
    • Tab Level: 1
    How to do it...
  14. Review the Field Sequence tab and make the required changes to the sequence, as shown in the following screenshot:
    How to do it...
  15. Follow the steps 18-19, mentioned in the Create a new window recipe, to create a menu, as shown in the following screenshot:
    How to do it...
  16. Log out and log in as GardenAdmin/GardenAdmin. You will see the Minutes Of Meeting menu item, as it appears in the following screenshot:
    How to do it...
  17. Click on the Minutes Of Meeting menu item. This will bring up the Minutes Of Meeting window with one tab, MOM. Our MOM window now has three tabs and looks more organized, as shown here in the following screenshot:
    How to do it...
  18. Add one or more participants for a MOM:
    How to do it...
  19. Add one or more discussion items for a MOM:
How to do it...

How it works...

In steps 1-5, we cleaned up the dictionary entries that were created so far, as we have changed the table structure of the c_mom table in this recipe and also introduced new tables, namely, c_mom_discussionline and c_mom_participantsline. If we don't do this, the dictionary entries will exist and may create problems when you try to recreate the dictionary entries for the modified table. In steps 6-7, we recreated the c_mom table (with a modified set of columns) and created c_mom_discussionline to save discussion line items for a MOM and the c_mom_participantsline table to save the list of MOM participants. In steps 9-12, we created the tabs and their fields using each one of these three tables.

There's more...

To delete the records, (Windows, Tabs, Fields, and so on.) use Delete Records or Delete Selected Items toolbar buttons (There's more... ) instead of deleting the records directly from the database tables using SQL statements. This is important for the proper cleanup of the records from that database. For example, ADempiere has translation tables (table name ending with _trl) where the entries get created, internally, by ADempiere. If you directly try to delete using SQL statements, you may miss these records.