BLOG

NEXT STEPS

Posts Tagged ‘OFBiz Tutorials’

OFBiz Tutorial- How To Use ECA’s To Extend Service Permission

Wednesday, June 16th, 2010

This OFBiz tutorial is the next part of our earlier tutorial “How to Setup User Permissions”.  See how using ECA’s can extend service permissions.

So far we have seen how to assign security permission to a user which will let the user access a particular application. The level of access to an application will depend on the permission(s) assigned to the user. You may want to allow the user to just view an application or maybe you want to allow them other possible permission options like creating new records, updating the existing records or deleting exiting records in a particular application.

You can also assign an admin permission to a user. This gives the user full access to an application so that the user can View, Create, Update and Delete records in a particular application.

Assigning a permission is not restricted to just one application, you can allow the user to access more then one application by assigning permissions related to other apps.

There are certain cases when a user has admin permission for an application but the user is not allowed to perform certain operation in the application. For example, if you want to view a product lookup screen in the “Asset Maint” application then you would need the permission of the Catalog application. The simplest option is to give the user all the required permissions. The downside of this approach is that this will also allow the user access to the Catalog application.

So in this case if you want the user to have access only to the “Asset Maint” app then you can do this by defining ECA (Event Condition Access) rules which will extend the permission of the other applications while still not allowing the user to access these application(s) other than “Asset Maint.”

The rule can be defined in a file under the sevicedef folder in the component directory tree as following.

OFBiz Tutorial Permissions-2-1a

This also requires the entry of this file in ofbiz-component.xml where secas.xml is the name of the above file.

OFBiz Tutorial Permissions-2-2a

Whenever the user tries to perform any catalog related operation in the “Asset Maint” application, the catalogPermissionCheck service will run first. We know that the user does not have any explicit permission to the Catalog application hence the service will return hasPermission flag as false. Every permission service implements a generic service interface and hasPermission is one of the boolean attibute that is returned by the permission service. If it is false it means that the user does not have sufficient permission.

Since we want to override the permission we define a permission service in the “Asset Maint” component. This service will check whether the user has permission to access the “Asset Maint” component or not instead of checking for Catalog permission. If the service returns a true for the hasPermission flag (which it will if the user has “Asset Maint” permissions) it means the user can access the catalog related screens in “Asset Maint.”

The code for the permission service will look like this: (Click to expand image.)

 OFBiz Tutorial Permissions-2-4a

This way without explicitly assigning the catalog permissions the user will still be able to access the product lookup screen in the “Asset Maint” application.

Similar you can add more rules to the ECA file to override the OFBiz user permissions of other applications in the “Asset Maint” application.

- Vikas

Vikas Mayur is a dynamic OFBiz developer working for HotWax Media as a Director of Software Development in India. He works in web based application and ERP software using OFBiz, which is a top level project of Apache Software Foundation.

OFBiz Tutorial: How to Setup User Permissions

Thursday, May 20th, 2010

In OFBiz, every application has a base permission (except a few like ecommerce, ofbizwebsite etc.) and users should have at least base OFBiz permission view or base permission admin to login in the application. Sometime base permission may consist of more then one permission and in that case both are required to login/access the application.

The base permission is defined in the ofbiz-component.xml file of each component. If the base permission consists of more then one permission then they are separated by a comma.

Below is a code snippet taken from Asset Maint component ofbiz-component file.

OFBiz Tutorial Permissions 1

We will now learn how to setup permissions for a new user to gain access to a back-end application while using an Asset Maint component as an example throughout the tutorial.

Just a note that we will not focus on the internal details of this component and we will only visit a couple of screens to see whether we have setup correct permission levels for the user or not.

Step by Step Guide

Lets first create a new user in the system. Login to the party manager application with username: admin and password: ofbiz and click on Create New link located at the top of the main screen.

The screen will provide a variety of options to choose from. Click on Create New Person.

OFBiz Tutorial Permissions 2

Enter the required fields and save the form.

OFBiz Tutorial Permissions 3

This will take you to the user profile screen.

Our next step is to create a user login for the new user. Click on Create New link on User Name(s) screen in the right column on the profile page.

OFBiz Tutorial Permissions 4

Enter the details as below and save the form.

User Login Id: joe.will
Current Password: ofbiz
Current Password Verify: ofbiz

Now coming back to the profile screen you will see that the new user login has appeared under the User Name(s) screen in the right column on the profile page.

Now click on the Security Group link. This will present you with a screen where you can add a security group to the user account. Security Group is basically a set of permissions where permissions are classified as VIEW, CREATE, UPDATE and DELETE. An admin security group contains all of these permissions. Select Asset Maint Admin group from the drop-down list. The From Date field is optional and if user does not enter it then the application will use the system’s current timestamp for this field. Thru Date is also optional but if specified then the security group will be valid for the user till the thru date has passed. You can also assign multiple security groups at the same time to the user. Save this form.

Now you have granted sufficient permission to the user to access the Asset Maint application.

OFBiz Tutorial Permissions 5

Note: The admin user is available only if demo data is installed. If only seed data is installed then you have to create the admin user explicitly through the command line with an ant target defined in the build file which is present at the root of the project. Run command create-admin-user-login from the terminal and follow onscreen instructions to complete this wizard.

Testing User’s Permissions

Logout from the party manager application and then you can login to the Asset Maint application with the new user. The user should be able to login in to this application without any issues and this signifies that the user has permission to VIEW this application.

Lets try to check whether the user has permission to perform CREATE operation in the application. Go to the Fixed Assets tab and click on New Fixed Asset link. Fill in the basic details as shown in the screenshot and click on update button. The user should be able to create new fixed asset record. This signifies that user has permission to perform create operation in the application.

OFBiz Tutorial Permissions 6

Similar you can check whether the user has UPDATE or DELETE permissions by updating or removing the fixed asset record.

Lets try to login into any other application (for example catalog) with the same user to check whether the system permits the user to access an application other than Asset Maint. As it would be obvious from the screenshot below that the security permissions assigned to the user is just enough to login and access Asset Maint application and not any other application.

Similar you can try to login into any other application with the same user and you will see the same result.

ofbiz-tutorial-permissions7

So far we have learned the basics of security permission in OFBiz and how we can assign these permissions to the user.

Hope you will enjoy this!

- Vikas

Vikas Mayur is a dynamic OFBiz developer working for HotWax Media as a Director of Software Development in India. He works in web based application and ERP software using OFBiz, which is a top level project of Apache Software Foundation.

OFBiz Tutorial – Dependent Selects for Prototype

Friday, May 14th, 2010

In my first OFBiz Tutorial, I will show you how to make dependent select boxes using Prototype.

Building a web UI that lives up to the expectations of contemporary web designers is a challenge that every web developer faces. One that has remained a pain for a while is Dependent Select boxes. jQuery has a nice UI plugin that serves the purpose, but I cannot use it because I am married to Prototype javascript framework. I finally decided to implement one using Prototype. Dependent Select by Sliver, a UI plugin for jQuery is nice and simple, so I decided to base my component on the same concept.

Here it is, Dependent class allows you to link two select boxes in a parent child relationship. Any two select boxes can be linked. All you need to do is

  1. Parent select box options should have unique value of title attribute.
  2. On child select box, class attribute of options should be set to title of their parent.
  3. In javascript Create new Dependent object by passing child and parent select boxes.

Here is sample code. (Copied from Dependent Select by Silver website)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<select name="selectme" id="selectme">
    <option value="">-- select --</option>
    <option value="1" title="flowers">Flowers</option>
    <option value="2" title="animals">Animals</option>
</select>
 
<select name="selectme2" id="selectme2">
    <option value="">-- select --</option>
    <option value="1" class="flowers">Sunflower</option>
    <option value="2" class="flowers">Rose</option>
    <option value="3" class="animals">Dog</option>
    <option value="4" class="animals">Cat</option>
</select>
 
<script>
    new Dependent($('selectme2'),$('selectme'));
</script>

My goal was to build a dependent select box that will work in complex enterprise application scenarios. A nonstandard case is when the value of a parent select box value is change by background code. It gets even more complex when select boxes are disabled. Good news is, our Dependent class is smart enough to deal with these use scenarios.

In the process of solving these problems I learned about an interesting feature in Prototype, it has a AOP like ability. We can modify behavior of existing code by wraping function inside of a custom wrapper function. A Prototype function wrap is applied to the setValue function on Element to handle the background select value changes and disabled select box value change.

I have enjoyed building and using this new component. Download the component from its home on the web. I hope you will be able to find some interesting applications for it as well.

- Anil

Anil Patel is Chief Development Officer at HotWax Media as well as an OFBiz project committer, PMC member, and active community contributor. He also studies karate! Anil will join other HotWax Media employees and advisors in periodically posting thoughts here related to OFBiz, eCommerce, ERP, and related topics.

OFBiz Tutorial – How to fulfill a sales order that has more than one ship group

Friday, April 23rd, 2010

In our last OFBiz tutorial by Jacopo we learned how to place a sales order comprising of multiple ship groups. Lets carry on with this OFBiz development tutorial and learn how to fulfill a sales order containing more than one ship group which is yet another interesting feature present OOTB.

The items in the ship group may differ from the previous tutorial and is not important though but in general the tutorial will present you with a step by step guide to fulfill a sales order.

Lets get started assuming that you have a very basic knowledge of warehouse.

The first step is to select a warehouse.

OFBiz Tutorial - Sales Order - Step 1

Select a warehouse from the drop-down and click on the submit button. Go to Picking tab to see the orders for picking.

OFBiz Tutorial - Sales Order - Step 2

The screen displays a list of orders that are in approved status. An order may require stock move prior to picking. There are a total of 4 grouping methods available OOTB to group the orders for picking namely: Group by Shipping Method, Group by Warehouse Area, Group by Number of Order Items and Zero grouping.

Lets just stick to zero grouping method i.e. when no grouping method is selected. From the screen below (part of the above screen) we find that order is not ready for picking yet and needs a stock move.

Stock move is moving inventory from a bulk location to a primary/pick location where a picker can actually pick the inventory items.

OFBiz Tutorial - Sales Order - Step 3

You cannot create a picklist until and unless order is ready for picking. Lets do the required stock move first.

OFBiz Tutorial - Sales Order - Step 4

Once we complete the stock move, the screen will show that no other stock move is required.

OFBiz Tutorial - Sales Order - Step 5

Lets go back to the picking screen and see whether the order is now ready for picking or not.

OFBiz Tutorial - Sales Order - Step 6

Now the order is ready for picking (see the second column) and we can create the picklist as well. After creating the picklist, we need to pick the order. This can be done through Manage Picklist screen.

OFBiz Tutorial - Sales Order - Step 7

Once the order is picked, change the status from the drop-down to Picked.

OFBiz Tutorial - Sales Order - Step 8

The order picking is now complete. Lets move further and learn how to pack the order. Click on Packing tab. On the packing screen, enter the order ID (left most) and the ship group ID (Right most) in the input box. The ship group though defaults to 00001 and you may only need to change it if you are packing the order for a different ship group other then 00001.

Click on Pack Order button. This will show the items that need to be packed for ship group 00001.

OFBiz Tutorial - Sales Order - Step 9

Click on Pack Item button. This will pack all the items in a single package and will show the number of package and items in these packages.

OFBiz Tutorial - Sales Order - Step 10

Click on Complete button. This will complete the packing of order for ship group 00001. A shipment and an invoice will be generated.

OFBiz Tutorial - Sales Order - Step 11

Now lets try to print the shipping label that can be affixed on this package. For this click on the shipment ID link and then go to Route Segments tab.

OFBiz Tutorial - Sales Order - Step 12

Click on Confirm Shipment with UPS button to confirm the shipment with UPS. Once the shipment is confirmed, a new button “Accept UPS Shipment Confirmation” will appear on the screen.

OFBiz Tutorial - Sales Order - Step 13

Click this button and the shipping label will be received from the UPS.

OFBiz Tutorial - Sales Order - Step 14

The shipping label can be viewed from View Label Image button and once printed can be affixed on each package.

You can now perform the same steps to pack items for ship group 00002. Once the order is packed for both ship groups the status of order will change to Completed.

OFBiz Tutorial - Sales Order - Step 15

This accomplishes the fulfillment of the order.

Vikas Mayur is a dynamic OFBiz developer working for HotWax Media as a Director of Software Development in India.  He works in web based application and ERP software using OFBiz, which is a top level project of Apache Software Foundation.

OFBiz Tutorial – Order Entry and Ship Groups

Friday, April 16th, 2010

A robust enterprise eCommerce system needs to handle manual order entries that are sometimes complex. In this OFBiz Tutorial we will go over how this works in OFBiz.

Example:

An order clerk has to place a sales order on behalf of a customer (order received by fax, by mail, by phone etc..); the order contains several items and the customer asks that the order is shipped with two (or more) shipments with different delivery dates and/or to different postal addresses and/or with different shipment methods or shipping instructions; the customer clearly specify the items to be assigned to each shipment.

How can you do this in OFBiz?

The order clerk can easily place an order like this by defining multiple ship groups: ship groups represent a way to group into different sets the items of an order and each ship group has its own shipping options, delivery dates, shipment address. Ship groups are created during order checkout.

For example, let’s suppose that the order clerk has to place an order for 10 units of the product with id WG-1111 and 5 units of the product with id GZ-1000.

The customer needs immediately 5 units of WG-1111 and prefers to pay for the quickest shipment method available, while all the 5 units of GZ-1000 and the remaining 5 units of WG-1111 (together with some promotional items) can wait and so they will be shipped using a cheaper and slower shipping method later.

Let’s do this step by step.

The first part is easy because it is exactly like placing a standard order:

go to the order entry screen and enter the customer id

sg1

add to the cart 10 units of WG-1111 and 5 units of GZ-1000 (don’t worry about the ship groups now, you will do this at checkout); if you are running the standard OFBiz demo you will also get some promotional items

sg2

now we are ready for the checkout and we click on the “Finalize Order” button;

sg3

the first checkout screen let us select the shipment address and this is where we add the second ship group that we need by clicking on the “New Ship Group” button:

sg4

the page will reload with two ship group sections; set the shipment address for each of them and click on the “Continue” button

sg5

in the next screen you will have the ability to move the items from one ship group to the other; initially all the items will be in the first ship group and the second one will be empty

sg6

using the drop down boxes and the quantity field near each item you can move the items to the second ship group

sg7

now click on the “Continue” button, the next screen will let you set the shipment method and options for each ship group; just make sure you select the proper method for each group;

sg8

sg9

The next steps are exactly the same as a standard order, so complete the checkout and confirm the order.

The exercise is now complete!

If you visit the order detail screen you will notice that there are now two boxes for the shipment information (one for each group):

sg10

You can now fulfill the order as usual and the only difference is that you will create two different shipments (one for each ship group): when the shipment is created from the ship group, OFBiz will create a shipment containing the items assigned to that ship group only.

- Jacopo

Jacopo Cappellato is VP of Technology at HotWax Media and has been involved with the OFBiz project since 2003. He is an OFBiz Project Committer and a member of both the OFBiz Project Management Committee and the Apache Software Foundation.Jacopo Cappellato - OFBiz Developer - OFBiz Expert