View source | Discuss this page | Page history | Printable version   
Main Page
Upload file
What links here
Recent changes

PDF Books
Show collection (0 pages)
Collections help


Retail:Developers Guide/How-to/Add Filters On Search Panel

How to add new filters on the search panel



This document aims to explain how to add a new filter on the search panel of Web POS from a module.

Bulbgraph.png   This feature is available starting from 15RRQ1

Create a module and add js content

The first part of this how to explains how to create a module and how to add a js file to the client side.

Add filter button

It is needed to create a new js file implementing OB.UI.SearchProductCharacteristicFilter kind

Here you can see a dummy example explaining the poperties that can be implemented.

  kind: 'OB.UI.SearchProductCharacteristicFilter',
  name: 'DUMMY_SearchProductCharacteristicFilter',
  // Set default conditions - Posible conditions: MORE_THAN, LESS_THAN, EQUALS, NOT_EQUALS, CONTAINS, NOT_CONTAINS
  defaults: [{
    condition: 'MORE_THAN',
    value: '0'
  // Add the parameters for the query
  sqlBuilder: function() {
    return {
      field: 'dummy',
      fieldType: 'Number' // or String or Date
  // Create the filters that the filter is going to apply
  sqlFilter: function() {
    return {
      where: null,
      filters: []
  lineAttributes: function() {
    // Return the property to add to the line created (if a line is added while the filter is active)
  postProcess: function(collection, callback) {
    // If it is needed to call to the backend or if it is needed to post process
  initComponents: function() {
    this.caption = OB.I18N.getLabel('DUMMY_Caption');
    this.text = OB.I18N.getLabel('DUMMY_FilterButton');

Add HQL query

Since RR15Q4: We are able to attach HQL query to Product Query in Web POS. Using new HQLCriteria functionality, we can define a HQL query from a module and then inject it to Product master data query.

Product Query

Below you can see where is injected the code defined in your module. The string $hqlCriteria will be replace dinamically with defined HQL queries.

  String hql = "select"
        + regularProductsHQLProperties.getHqlSelect()
        + "FROM OBRETCO_Prol_Product as pli left outer join pli.product.image img inner join pli.product as product, "
        + "PricingProductPrice ppp, " + "PricingPriceListVersion pplv "
        + "WHERE  $filtersCriteria AND $hqlCriteria AND (pli.obretcoProductlist = '"
        + productList.getId() + "') " + "AND (" + "'" + priceListVersion.getId() + "'"
        + ") AND (" + " =" + ") AND ("
        + " =" + ") ";

What add in your module

First, we need to define a java file to define our HQL query. You have to define a @Qualifier with the unique name of your piece of code in order to inject later by javascript. It is enough to extend HQLCriteriaProcess and implement getHQLFilter method returning the value of the query. See in the example that you are able to define parameters in the query, these paramater values will be set in javascript injection.

package org.openbravo.retail.complementary;
import javax.enterprise.context.ApplicationScoped;
import org.openbravo.client.kernel.ComponentProvider.Qualifier;
public class ComplementaryHQLCriteria extends HQLCriteriaProcess {
  public String getHQLFilter() {
    return " exists (select 1 from OBRECP_ComplementaryProduct as cp where  cp.complementaryProduct = pli.product and = '$1') ";

In client side, as explained before, we need to add some code to inject defined query. We will create a component using kind: 'OB.UI.SearchProductCharacteristicFilter'. This component must have hqlCriteria method where we will define the criteria. See below code, name defined in the java is needed to identify oue piece of code and do not forget to define operator as OB.Dal.FILTER. See that yuo must include paramaters as an array in order.

  kind: 'OB.UI.SearchProductCharacteristicFilter',
  name: 'OBRECP_SearchProductCharacteristicFilter',
  hqlCriteria: function () {
    return [{
      columns: [],
      operator: OB.Dal.FILTER,
      value: 'Complementary_Filter',
      params: [this.productId]
    }, {
      columns: ['ispack'],
      operator: 'equals',
      value: false,
      isId: true

That changes will attach your query with set parameters in Product HQL query. Be careful, take into accout that your code will be injected in a query and you must not break HQL syntax.

Retrieved from ""

This page has been accessed 547 times. This page was last modified on 7 September 2015, at 11:52. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.