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

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
主站蜘蛛池模板: 霍邱县| 佛冈县| 灵寿县| 家居| 蓬莱市| 马关县| 霍州市| 焦作市| 天峨县| 青神县| 花莲市| 景德镇市| 堆龙德庆县| 南澳县| 甘肃省| 清镇市| 靖宇县| 兰溪市| 靖宇县| 山阴县| 崇礼县| 陇西县| 措美县| 万年县| 平凉市| 湘潭县| 唐山市| 大关县| 新干县| 永胜县| 衡南县| 岢岚县| 蓬溪县| 修武县| 班玛县| 潢川县| 英吉沙县| 上杭县| 城固县| 寿宁县| 保康县|