Fixes issue 20703: Orphan line: don't support products with attributes
authorMikel Irurita <mikel.irurita@openbravo.com>
Thu, 07 Jun 2012 18:25:04 +0200
changeset 16741 c81d38ff1553
parent 16740 b372bd438d77
child 16742 05873cc04398
Fixes issue 20703: Orphan line: don't support products with attributes
src-db/database/sourcedata/AD_PROCESS_PARA.xml
src-db/database/sourcedata/AD_REFERENCE.xml
src-db/database/sourcedata/OBUISEL_SELECTOR.xml
src-db/database/sourcedata/OBUISEL_SELECTOR_FIELD.xml
src/org/openbravo/erpCommon/ad_actionButton/RMInsertOrphanLine.java
--- a/src-db/database/sourcedata/AD_PROCESS_PARA.xml	Thu Jun 07 18:00:36 2012 +0200
+++ b/src-db/database/sourcedata/AD_PROCESS_PARA.xml	Thu Jun 07 18:25:04 2012 +0200
@@ -4178,26 +4178,6 @@
 <!--7144D3B5D3254D118A501450DD94CC70-->  <AD_ELEMENT_ID><![CDATA[839]]></AD_ELEMENT_ID>
 <!--7144D3B5D3254D118A501450DD94CC70--></AD_PROCESS_PARA>
 
-<!--738981E2FB8A4CB9BCAB2629E799B00B--><AD_PROCESS_PARA>
-<!--738981E2FB8A4CB9BCAB2629E799B00B-->  <AD_PROCESS_PARA_ID><![CDATA[738981E2FB8A4CB9BCAB2629E799B00B]]></AD_PROCESS_PARA_ID>
-<!--738981E2FB8A4CB9BCAB2629E799B00B-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
-<!--738981E2FB8A4CB9BCAB2629E799B00B-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
-<!--738981E2FB8A4CB9BCAB2629E799B00B-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
-<!--738981E2FB8A4CB9BCAB2629E799B00B-->  <NAME><![CDATA[Attribute Set Value]]></NAME>
-<!--738981E2FB8A4CB9BCAB2629E799B00B-->  <DESCRIPTION><![CDATA[An attribute associated with a product as part of an attribute set.]]></DESCRIPTION>
-<!--738981E2FB8A4CB9BCAB2629E799B00B-->  <HELP><![CDATA[The values of the actual Product Attributes]]></HELP>
-<!--738981E2FB8A4CB9BCAB2629E799B00B-->  <AD_PROCESS_ID><![CDATA[23D1B163EC0B41F790CE39BF01DA320E]]></AD_PROCESS_ID>
-<!--738981E2FB8A4CB9BCAB2629E799B00B-->  <SEQNO><![CDATA[20]]></SEQNO>
-<!--738981E2FB8A4CB9BCAB2629E799B00B-->  <AD_REFERENCE_ID><![CDATA[95E2A8B50A254B2AAE6774B8C2F28120]]></AD_REFERENCE_ID>
-<!--738981E2FB8A4CB9BCAB2629E799B00B-->  <AD_REFERENCE_VALUE_ID><![CDATA[A3AB4DB96AAF4F72B3D431282D49F1ED]]></AD_REFERENCE_VALUE_ID>
-<!--738981E2FB8A4CB9BCAB2629E799B00B-->  <COLUMNNAME><![CDATA[M_AttributeSetInstance_ID]]></COLUMNNAME>
-<!--738981E2FB8A4CB9BCAB2629E799B00B-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
-<!--738981E2FB8A4CB9BCAB2629E799B00B-->  <FIELDLENGTH><![CDATA[32]]></FIELDLENGTH>
-<!--738981E2FB8A4CB9BCAB2629E799B00B-->  <ISMANDATORY><![CDATA[N]]></ISMANDATORY>
-<!--738981E2FB8A4CB9BCAB2629E799B00B-->  <ISRANGE><![CDATA[N]]></ISRANGE>
-<!--738981E2FB8A4CB9BCAB2629E799B00B-->  <AD_ELEMENT_ID><![CDATA[2019]]></AD_ELEMENT_ID>
-<!--738981E2FB8A4CB9BCAB2629E799B00B--></AD_PROCESS_PARA>
-
 <!--73C3F0DC9B624A0BB72D5A5952FD8135--><AD_PROCESS_PARA>
 <!--73C3F0DC9B624A0BB72D5A5952FD8135-->  <AD_PROCESS_PARA_ID><![CDATA[73C3F0DC9B624A0BB72D5A5952FD8135]]></AD_PROCESS_PARA_ID>
 <!--73C3F0DC9B624A0BB72D5A5952FD8135-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_REFERENCE.xml	Thu Jun 07 18:00:36 2012 +0200
+++ b/src-db/database/sourcedata/AD_REFERENCE.xml	Thu Jun 07 18:25:04 2012 +0200
@@ -4852,19 +4852,6 @@
 <!--A26BA480E2014707B47257024C3CBFF7-->  <ISVALUEDISPLAYED><![CDATA[N]]></ISVALUEDISPLAYED>
 <!--A26BA480E2014707B47257024C3CBFF7--></AD_REFERENCE>
 
-<!--A3AB4DB96AAF4F72B3D431282D49F1ED--><AD_REFERENCE>
-<!--A3AB4DB96AAF4F72B3D431282D49F1ED-->  <AD_REFERENCE_ID><![CDATA[A3AB4DB96AAF4F72B3D431282D49F1ED]]></AD_REFERENCE_ID>
-<!--A3AB4DB96AAF4F72B3D431282D49F1ED-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
-<!--A3AB4DB96AAF4F72B3D431282D49F1ED-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
-<!--A3AB4DB96AAF4F72B3D431282D49F1ED-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
-<!--A3AB4DB96AAF4F72B3D431282D49F1ED-->  <NAME><![CDATA[Product Attribute Selector]]></NAME>
-<!--A3AB4DB96AAF4F72B3D431282D49F1ED-->  <HELP><![CDATA[Selector of attribute instance used by selected attribute.]]></HELP>
-<!--A3AB4DB96AAF4F72B3D431282D49F1ED-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
-<!--A3AB4DB96AAF4F72B3D431282D49F1ED-->  <ISBASEREFERENCE><![CDATA[N]]></ISBASEREFERENCE>
-<!--A3AB4DB96AAF4F72B3D431282D49F1ED-->  <PARENTREFERENCE_ID><![CDATA[95E2A8B50A254B2AAE6774B8C2F28120]]></PARENTREFERENCE_ID>
-<!--A3AB4DB96AAF4F72B3D431282D49F1ED-->  <ISVALUEDISPLAYED><![CDATA[N]]></ISVALUEDISPLAYED>
-<!--A3AB4DB96AAF4F72B3D431282D49F1ED--></AD_REFERENCE>
-
 <!--A6BDFA712FF948CE903C4C463E832FC1--><AD_REFERENCE>
 <!--A6BDFA712FF948CE903C4C463E832FC1-->  <AD_REFERENCE_ID><![CDATA[A6BDFA712FF948CE903C4C463E832FC1]]></AD_REFERENCE_ID>
 <!--A6BDFA712FF948CE903C4C463E832FC1-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/OBUISEL_SELECTOR.xml	Thu Jun 07 18:00:36 2012 +0200
+++ b/src-db/database/sourcedata/OBUISEL_SELECTOR.xml	Thu Jun 07 18:25:04 2012 +0200
@@ -1,28 +1,5 @@
 <?xml version='1.0' encoding='UTF-8'?>
 <data>
-<!--225A4BD46912482EAF399C83C6564E08--><OBUISEL_SELECTOR>
-<!--225A4BD46912482EAF399C83C6564E08-->  <OBUISEL_SELECTOR_ID><![CDATA[225A4BD46912482EAF399C83C6564E08]]></OBUISEL_SELECTOR_ID>
-<!--225A4BD46912482EAF399C83C6564E08-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
-<!--225A4BD46912482EAF399C83C6564E08-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
-<!--225A4BD46912482EAF399C83C6564E08-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
-<!--225A4BD46912482EAF399C83C6564E08-->  <NAME><![CDATA[Product Attribute]]></NAME>
-<!--225A4BD46912482EAF399C83C6564E08-->  <AD_REFERENCE_ID><![CDATA[A3AB4DB96AAF4F72B3D431282D49F1ED]]></AD_REFERENCE_ID>
-<!--225A4BD46912482EAF399C83C6564E08-->  <AD_TABLE_ID><![CDATA[559]]></AD_TABLE_ID>
-<!--225A4BD46912482EAF399C83C6564E08-->  <FILTER_EXPRESSION><![CDATA[if (OB.getParameters().get('inpmProductId') != null) { "trx.product.id = '" +OB.getParameters().get('inpmProductId') +"'" } else { "1=2" }]]></FILTER_EXPRESSION>
-<!--225A4BD46912482EAF399C83C6564E08-->  <OBCLKER_TEMPLATE_ID><![CDATA[9314DE8599AD44E7BFC4CC50699042AB]]></OBCLKER_TEMPLATE_ID>
-<!--225A4BD46912482EAF399C83C6564E08-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
-<!--225A4BD46912482EAF399C83C6564E08-->  <VALUEFIELD_ID><![CDATA[D1C291E19F1D40E4B74C14445B9F3E64]]></VALUEFIELD_ID>
-<!--225A4BD46912482EAF399C83C6564E08-->  <DISPLAYFIELD_ID><![CDATA[6F78BC009EFF4AC29A5F0F74DD1D8C19]]></DISPLAYFIELD_ID>
-<!--225A4BD46912482EAF399C83C6564E08-->  <SUGGESTIONTEXTMATCHSTYLE><![CDATA[substring]]></SUGGESTIONTEXTMATCHSTYLE>
-<!--225A4BD46912482EAF399C83C6564E08-->  <POPUPTEXTMATCHSTYLE><![CDATA[startsWith]]></POPUPTEXTMATCHSTYLE>
-<!--225A4BD46912482EAF399C83C6564E08-->  <HQL><![CDATA[SELECT DISTINCT asi.id AS asiid, CASE asi.id WHEN '0' THEN '--' ELSE asi.description END AS asiname
-FROM MaterialMgmtMaterialTransaction trx
-JOIN trx.attributeSetValue asi
-WHERE @additional_filters@]]></HQL>
-<!--225A4BD46912482EAF399C83C6564E08-->  <ENTITY_ALIAS><![CDATA[asi]]></ENTITY_ALIAS>
-<!--225A4BD46912482EAF399C83C6564E08-->  <CUSTOM_QUERY><![CDATA[Y]]></CUSTOM_QUERY>
-<!--225A4BD46912482EAF399C83C6564E08--></OBUISEL_SELECTOR>
-
 <!--2E64F551C7C4470C80C29DBA24B34A5F--><OBUISEL_SELECTOR>
 <!--2E64F551C7C4470C80C29DBA24B34A5F-->  <OBUISEL_SELECTOR_ID><![CDATA[2E64F551C7C4470C80C29DBA24B34A5F]]></OBUISEL_SELECTOR_ID>
 <!--2E64F551C7C4470C80C29DBA24B34A5F-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/OBUISEL_SELECTOR_FIELD.xml	Thu Jun 07 18:00:36 2012 +0200
+++ b/src-db/database/sourcedata/OBUISEL_SELECTOR_FIELD.xml	Thu Jun 07 18:25:04 2012 +0200
@@ -572,26 +572,6 @@
 <!--63507B832CF94D8BB30286ED4369E55B-->  <SHOWINPICKLIST><![CDATA[N]]></SHOWINPICKLIST>
 <!--63507B832CF94D8BB30286ED4369E55B--></OBUISEL_SELECTOR_FIELD>
 
-<!--6F78BC009EFF4AC29A5F0F74DD1D8C19--><OBUISEL_SELECTOR_FIELD>
-<!--6F78BC009EFF4AC29A5F0F74DD1D8C19-->  <OBUISEL_SELECTOR_FIELD_ID><![CDATA[6F78BC009EFF4AC29A5F0F74DD1D8C19]]></OBUISEL_SELECTOR_FIELD_ID>
-<!--6F78BC009EFF4AC29A5F0F74DD1D8C19-->  <OBUISEL_SELECTOR_ID><![CDATA[225A4BD46912482EAF399C83C6564E08]]></OBUISEL_SELECTOR_ID>
-<!--6F78BC009EFF4AC29A5F0F74DD1D8C19-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
-<!--6F78BC009EFF4AC29A5F0F74DD1D8C19-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
-<!--6F78BC009EFF4AC29A5F0F74DD1D8C19-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
-<!--6F78BC009EFF4AC29A5F0F74DD1D8C19-->  <NAME><![CDATA[Description]]></NAME>
-<!--6F78BC009EFF4AC29A5F0F74DD1D8C19-->  <ISCENTRALLYMAINTAINED><![CDATA[N]]></ISCENTRALLYMAINTAINED>
-<!--6F78BC009EFF4AC29A5F0F74DD1D8C19-->  <SORT><![CDATA[Y]]></SORT>
-<!--6F78BC009EFF4AC29A5F0F74DD1D8C19-->  <FILTER><![CDATA[Y]]></FILTER>
-<!--6F78BC009EFF4AC29A5F0F74DD1D8C19-->  <SEARCHINSUGGESTIONBOX><![CDATA[Y]]></SEARCHINSUGGESTIONBOX>
-<!--6F78BC009EFF4AC29A5F0F74DD1D8C19-->  <SHOWINGRID><![CDATA[N]]></SHOWINGRID>
-<!--6F78BC009EFF4AC29A5F0F74DD1D8C19-->  <SORTNO><![CDATA[0]]></SORTNO>
-<!--6F78BC009EFF4AC29A5F0F74DD1D8C19-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
-<!--6F78BC009EFF4AC29A5F0F74DD1D8C19-->  <ISOUTFIELD><![CDATA[N]]></ISOUTFIELD>
-<!--6F78BC009EFF4AC29A5F0F74DD1D8C19-->  <DISPLAY_EXPRESSION><![CDATA[asiname]]></DISPLAY_EXPRESSION>
-<!--6F78BC009EFF4AC29A5F0F74DD1D8C19-->  <AD_REFERENCE_ID><![CDATA[10]]></AD_REFERENCE_ID>
-<!--6F78BC009EFF4AC29A5F0F74DD1D8C19-->  <SHOWINPICKLIST><![CDATA[Y]]></SHOWINPICKLIST>
-<!--6F78BC009EFF4AC29A5F0F74DD1D8C19--></OBUISEL_SELECTOR_FIELD>
-
 <!--7167B12683FD4B8C99FA777C92A39BC5--><OBUISEL_SELECTOR_FIELD>
 <!--7167B12683FD4B8C99FA777C92A39BC5-->  <OBUISEL_SELECTOR_FIELD_ID><![CDATA[7167B12683FD4B8C99FA777C92A39BC5]]></OBUISEL_SELECTOR_FIELD_ID>
 <!--7167B12683FD4B8C99FA777C92A39BC5-->  <OBUISEL_SELECTOR_ID><![CDATA[4C8BC3E8E56441F4B8C98C684A0C9212]]></OBUISEL_SELECTOR_ID>
@@ -1095,26 +1075,6 @@
 <!--CD0E2A0608A24055BAE8B765AF211846-->  <SHOWINPICKLIST><![CDATA[N]]></SHOWINPICKLIST>
 <!--CD0E2A0608A24055BAE8B765AF211846--></OBUISEL_SELECTOR_FIELD>
 
-<!--D1C291E19F1D40E4B74C14445B9F3E64--><OBUISEL_SELECTOR_FIELD>
-<!--D1C291E19F1D40E4B74C14445B9F3E64-->  <OBUISEL_SELECTOR_FIELD_ID><![CDATA[D1C291E19F1D40E4B74C14445B9F3E64]]></OBUISEL_SELECTOR_FIELD_ID>
-<!--D1C291E19F1D40E4B74C14445B9F3E64-->  <OBUISEL_SELECTOR_ID><![CDATA[225A4BD46912482EAF399C83C6564E08]]></OBUISEL_SELECTOR_ID>
-<!--D1C291E19F1D40E4B74C14445B9F3E64-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
-<!--D1C291E19F1D40E4B74C14445B9F3E64-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
-<!--D1C291E19F1D40E4B74C14445B9F3E64-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
-<!--D1C291E19F1D40E4B74C14445B9F3E64-->  <NAME><![CDATA[Id]]></NAME>
-<!--D1C291E19F1D40E4B74C14445B9F3E64-->  <ISCENTRALLYMAINTAINED><![CDATA[N]]></ISCENTRALLYMAINTAINED>
-<!--D1C291E19F1D40E4B74C14445B9F3E64-->  <SORT><![CDATA[Y]]></SORT>
-<!--D1C291E19F1D40E4B74C14445B9F3E64-->  <FILTER><![CDATA[Y]]></FILTER>
-<!--D1C291E19F1D40E4B74C14445B9F3E64-->  <SEARCHINSUGGESTIONBOX><![CDATA[N]]></SEARCHINSUGGESTIONBOX>
-<!--D1C291E19F1D40E4B74C14445B9F3E64-->  <SHOWINGRID><![CDATA[N]]></SHOWINGRID>
-<!--D1C291E19F1D40E4B74C14445B9F3E64-->  <SORTNO><![CDATA[0]]></SORTNO>
-<!--D1C291E19F1D40E4B74C14445B9F3E64-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
-<!--D1C291E19F1D40E4B74C14445B9F3E64-->  <ISOUTFIELD><![CDATA[N]]></ISOUTFIELD>
-<!--D1C291E19F1D40E4B74C14445B9F3E64-->  <DISPLAY_EXPRESSION><![CDATA[asiid]]></DISPLAY_EXPRESSION>
-<!--D1C291E19F1D40E4B74C14445B9F3E64-->  <AD_REFERENCE_ID><![CDATA[13]]></AD_REFERENCE_ID>
-<!--D1C291E19F1D40E4B74C14445B9F3E64-->  <SHOWINPICKLIST><![CDATA[N]]></SHOWINPICKLIST>
-<!--D1C291E19F1D40E4B74C14445B9F3E64--></OBUISEL_SELECTOR_FIELD>
-
 <!--D2331E1502BD481A920747C46865FFA8--><OBUISEL_SELECTOR_FIELD>
 <!--D2331E1502BD481A920747C46865FFA8-->  <OBUISEL_SELECTOR_FIELD_ID><![CDATA[D2331E1502BD481A920747C46865FFA8]]></OBUISEL_SELECTOR_FIELD_ID>
 <!--D2331E1502BD481A920747C46865FFA8-->  <OBUISEL_SELECTOR_ID><![CDATA[4C8BC3E8E56441F4B8C98C684A0C9212]]></OBUISEL_SELECTOR_ID>
--- a/src/org/openbravo/erpCommon/ad_actionButton/RMInsertOrphanLine.java	Thu Jun 07 18:00:36 2012 +0200
+++ b/src/org/openbravo/erpCommon/ad_actionButton/RMInsertOrphanLine.java	Thu Jun 07 18:25:04 2012 +0200
@@ -36,10 +36,8 @@
 import org.openbravo.model.common.order.Order;
 import org.openbravo.model.common.order.OrderLine;
 import org.openbravo.model.common.order.ReturnReason;
-import org.openbravo.model.common.plm.AttributeSetInstance;
 import org.openbravo.model.common.plm.Product;
 import org.openbravo.model.financialmgmt.tax.TaxRate;
-import org.openbravo.model.materialmgmt.transaction.MaterialTransaction;
 import org.openbravo.model.pricing.pricelist.PriceList;
 import org.openbravo.model.pricing.pricelist.PriceListVersion;
 import org.openbravo.model.pricing.pricelist.ProductPrice;
@@ -58,7 +56,6 @@
 
     final String strOrderId = (String) bundle.getParams().get("C_Order_ID");
     final String strProductId = (String) bundle.getParams().get("mProductId");
-    final String strASIId = (String) bundle.getParams().get("mAttributesetinstanceId");
     final String strReturnedQty = (String) bundle.getParams().get("returned");
     final BigDecimal returnedQty = new BigDecimal(strReturnedQty);
     final String strUnitPrice = (String) bundle.getParams().get("pricestd");
@@ -67,37 +64,6 @@
 
     Order order = OBDal.getInstance().get(Order.class, strOrderId);
     Product product = OBDal.getInstance().get(Product.class, strProductId);
-    AttributeSetInstance asi = null;
-    if (product.isStocked() && ITEM.equals(product.getProductType())) {
-      asi = OBDal.getInstance()
-          .get(AttributeSetInstance.class, strASIId.isEmpty() ? "0" : strASIId);
-    }
-
-    if (asi != null) {
-      // Check attributesetinstance has been used with the product
-      StringBuffer where = new StringBuffer();
-      where.append(" as trx");
-      where.append(" where trx." + MaterialTransaction.PROPERTY_PRODUCT + " = :product");
-      where.append("   and trx." + MaterialTransaction.PROPERTY_ATTRIBUTESETVALUE + " = :asi");
-      OBQuery<MaterialTransaction> attrQry = OBDal.getInstance().createQuery(
-          MaterialTransaction.class, where.toString());
-      attrQry.setNamedParameter("product", product);
-      attrQry.setNamedParameter("asi", asi);
-      if (attrQry.count() == 0) {
-        Map<String, String> parameters = new HashMap<String, String>();
-        parameters.put("product", product.getName());
-        parameters.put("attribute", asi.getDescription());
-        String message = OBMessageUtils.messageBD("WrongAttributeForProduct");
-        msg.setMessage(OBMessageUtils.parseTranslation(message, parameters));
-        msg.setTitle(OBMessageUtils.messageBD("Error"));
-        msg.setType("Error");
-        bundle.setResult(msg);
-        return;
-      }
-      if ("0".equals(asi.getId())) {
-        asi = null;
-      }
-    }
 
     OBContext.setAdminMode(true);
     try {
@@ -109,7 +75,7 @@
       newOrderLine.setWarehouse(order.getWarehouse());
       newOrderLine.setCurrency(order.getCurrency());
       newOrderLine.setProduct(product);
-      newOrderLine.setAttributeSetValue(asi);
+      newOrderLine.setAttributeSetValue(null);
       newOrderLine.setUOM(product.getUOM());
       newOrderLine.setOrderedQuantity(returnedQty.negate());