
# HG changeset patch
# User Eduardo Argal Guibert <eduardo.argal@openbravo.com>
# Date 1506617251 -7200
# Node ID 1d00ab6a8a11086627e5e5b67717fec69e863e9d
# Parent  b5edd4493bcfe807947a4e81e6458307a841152d
[Cancel And New] Changes LoadedProduct to retrieve price from order line when no product price is present (2)

diff -r b5edd4493bcf -r 1d00ab6a8a11 src/org/openbravo/retail/posterminal/master/LoadedProduct.java
--- a/src/org/openbravo/retail/posterminal/master/LoadedProduct.java	Thu Sep 28 18:44:57 2017 +0200
+++ b/src/org/openbravo/retail/posterminal/master/LoadedProduct.java	Thu Sep 28 18:47:31 2017 +0200
@@ -24,6 +24,7 @@
 import org.codehaus.jettison.json.JSONObject;
 import org.openbravo.client.kernel.ComponentProvider.Qualifier;
 import org.openbravo.dal.core.OBContext;
+import org.openbravo.mobile.core.model.HQLProperty;
 import org.openbravo.mobile.core.model.HQLPropertyList;
 import org.openbravo.mobile.core.model.ModelExtension;
 import org.openbravo.mobile.core.model.ModelExtensionUtils;
@@ -49,9 +50,15 @@
     HQLPropertyList regularProductsHQLProperties = ModelExtensionUtils.getPropertyExtensions(
         extensions, args);
     regularProductsHQLProperties.addAll(ProductProperties.getMainProductHQLProperties(args));
+    regularProductsHQLProperties.add(new HQLProperty(
+        "coalesce(ppp.standardPrice, ollist.listPrice)", "standardPrice", 10));
     String hql = "select"
         + regularProductsHQLProperties.getHqlSelect()
-        + "FROM Product product left outer join product.uOM uom, PricingProductPrice ppp WHERE ppp.product=product and ppp.priceListVersion.id=:priceListVersionId and product.id=:productId";
+        + "FROM Product product "
+        + "left outer join product.uOM uom "
+        + "left outer join product.pricingProductPriceList ppp with ppp.priceListVersion.id=:priceListVersionId "
+        + "left outer join product.orderLineList ollist with ollist.id=:salesOrderLineId "
+        + "WHERE product.id=:productId ";
     products.add(hql);
     return products;
 
@@ -65,6 +72,10 @@
     paramValues.put("priceListVersionId", priceListVersion.getId());
     paramValues.put("productId", jsonsent.getJSONObject("parameters").getJSONObject("productId")
         .getString("value"));
+    paramValues.put(
+        "salesOrderLineId",
+        jsonsent.getJSONObject("parameters").has("salesOrderLineId") ? jsonsent
+            .getJSONObject("parameters").getJSONObject("salesOrderLineId").getString("value") : "");
     return paramValues;
   }
 }
\ No newline at end of file
diff -r b5edd4493bcf -r 1d00ab6a8a11 web/org.openbravo.retail.posterminal/js/model/order.js
--- a/web/org.openbravo.retail.posterminal/js/model/order.js	Thu Sep 28 18:44:57 2017 +0200
+++ b/web/org.openbravo.retail.posterminal/js/model/order.js	Thu Sep 28 18:47:31 2017 +0200
@@ -5023,7 +5023,8 @@
                 }, null, function () {
                   //Empty
                   new OB.DS.Request('org.openbravo.retail.posterminal.master.LoadedProduct').exec({
-                    productId: iter.id
+                    productId: iter.id,
+                    salesOrderLineId: iter.lineId
                   }, function (data) {
                     addLineForProduct(OB.Dal.transform(OB.Model.Product, data[0]));
                   }, function () {

