官术网_书友最值得收藏!

  • ADempiere 3.6 Cookbook
  • Ajit Kumar
  • 504字
  • 2021-04-09 21:40:57

Creating a read-only tab

Sometimes there may be a need where not the complete window should be made read-only. Rather, a particular tab needs to be made read-only. For example, there is a user who, as per their role, shall capture the payments against an invoice. He/she should not be allowed to create an invoice in the system. To address this need, we can have a window where one tab is to capture the payment detail and another one showing the outstanding invoices, which we will make read-only. This way, on the single window, the user will be able to refer to the outstanding invoices and at the same time receive payments towards them.

In our MOM case study, Let us say we want to add a rule that states only an admin user shall be allowed to edit the discussion items of an MOM. Let us see how we can do this.

How to do it...

  1. Log in as System/System with the System Administrator role.
  2. Go to the Window, Tab, and Field window and look for the Minutes Of Meeting window.
  3. Go to the Discussion Detail tab detail on the Tab.
  4. Specify the following in the Read Only Logic field, as shown in the following screenshot:
    @#AD_Role_Name@='GardenWorld User'
    
    How to do it...
  5. Log out and log in as GardenUser/GardenUser with the GardenWorld User role.
  6. Go to the Minutes Of Meeting window. The system will show you the list and the New Record button will be disabled, because, for this role, we have set the read-only logic. Also notice that the read-only tab label is displayed in italic, as shown in the following screenshot:
    How to do it...
  7. Log out and log in as GardenAdmin/GardenAdmin with the GardenWorld Admin role.
  8. Go to the Minutes Of Meeting window. This user will have the permission to create new discussion items, as shown in the following screenshot:
How to do it...

How it works...

The Read Only Logic, in step 3, is the key here. ADempiere evaluates the expression mentioned in this field at the time of displaying a tab. If the expression evaluates to true, then the tab becomes read-only. Otherwise, it remains editable. You can build the expressions using this context. In this recipe, we used the #AD_Role_Name context variable in the expression to check if the role name of the current logged in user is "GardenWorld user", and then made the tab read-only. To view the context information, click on Tools | Preference on any window and go to the Context tab.

There's more...

In the recipe, we saw how to make a tab read-only based on certain conditions, which get evaluated at runtime. There may be a case where a tab has to be read-only in all the cases.

Making the tab read-only for everyone

Say, irrespective of the user or role or any other condition, you want to make a tab read-only. To do this, on the Tab tab of the Window, Tab, and Field windows for the intended tab, check the Read Only checkbox and save it, as shown in the following screenshot:

Making the tab read-only for everyone
主站蜘蛛池模板: 华容县| 瑞金市| 乐东| 辛集市| 神农架林区| 梁平县| 道孚县| 象州县| 湘阴县| 富锦市| 柏乡县| 孝感市| 南京市| 临清市| 阳原县| 公主岭市| 阿克| 嘉善县| 重庆市| 土默特左旗| 运城市| 桐庐县| 确山县| 泰和县| 常宁市| 诸暨市| 宝山区| 小金县| 通山县| 鄱阳县| 板桥市| 福泉市| 揭东县| 平顶山市| 全椒县| 卓尼县| 团风县| 玛纳斯县| 漳州市| 壶关县| 行唐县|